Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Image ¶
Image computes the PSNR, in decibels, between two equal-bounds images, treating each pixel as 4 RGBA channels (see psnr's doc comment for the alpha-inclusion rationale).
When both images are *image.RGBA, their Pix bytes are read directly, skipping the At()/color.Color conversion on every pixel: image.RGBA already stores alpha-premultiplied 8-bit channels, which is exactly what At(x, y).RGBA() would widen to 16-bit and this package truncates back down to 8-bit — so the fast path is byte-identical to the general path for that type. Other concrete types (e.g. *image.NRGBA, which stores non-premultiplied channels and would change what's being measured if read raw) fall back to the At()-based loop.
func PSNR ¶
PSNR computes the peak signal-to-noise ratio, in decibels, between two equal-length RGBA pixel buffers (4 bytes per pixel: R, G, B, A). Higher is more similar; identical inputs report +Inf, matching the conventional definition of PSNR for a zero mean squared error.
Alpha is included in the error term with the same weight as color, generalizing the standard 3-channel RGB PSNR formula to 4 channels: dividing by len(a) (== 4 * width * height) rather than 3 * width * height. This is a whole-buffer fidelity metric, not a perceptual one.
Types ¶
This section is empty.