Scroll to navigation

Pnmpsnr User Manual(0) Pnmpsnr User Manual(0)

NAME

pnmpsnr - compute the difference between two images (the PSNR)

SYNOPSIS

pnmpsnr

[pnmfile1]

[pnmfile2]

[-rgb] [-machine] [-max=n]

Minimum unique abbreviations of options are acceptable. You may use double hyphens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value.

DESCRIPTION

This program is part of Netpbm(1).

pnmpsnr reads two PBM, PGM, or PPM files, or PAM equivalents, as input and prints the magnitude of difference between the two images as a peak signal-to-noise ratio (PSNR) This metric is typically used in image compression papers to rate the distortion between original and decoded image.

If the inputs are PBM or PGM, pnmpsnr prints the PSNR of the luminance only. Otherwise, it prints the separate PSNRs of the luminance, and chrominance (Cb and Cr) components of the colors.

The PSNR of a given component is the ratio of the maximum mean square difference of component values that could exist between the two images (a measure of the information content in an image) to the actual mean square difference for the two subject images. It is expressed as a decibel value.

The mean square difference of a component for two images is the mean square difference of the component value, comparing each pixel with the pixel in the same position of the other image. For the purposes of this computation, components are normalized to the scale [0..1].

The maximum mean square difference is identically 1.

So the higher the PSNR, the closer the images are. A luminance PSNR of 20 means the mean square difference of the luminances of the pixels is 100 times less than the maximum possible difference, i.e. 0.01.

Note that the word "peak" is a misnomer; there is no maximum involved; the metric is a mean. But "peak signal to noise ratio" is for some reason the common term for this measurement.

pnmpsnr reports the PSNR either in human-friendly form or in machine-friendly form (see -machine).

OPTIONS

This option causes pnmpsnr to compare the red, green, and blue components of the color rather than the luminance and chrominance components. It has no effect on a grayscale image.

This option was new in Netpbm 10.71 (June 2015).

This option causes pnmpsnr to report the PSNRs in machine-friendly form, so another program can easily use the information.

The output is a single line. It contains one floating point decimal number for each color component, with a single space between every two. (This means there are either 1 or 3 numbers). For the YCbCr color space (no -rgb), they are in the order Y, Cb, Cr. For the RGB color space (-rgb), they are in R, G, B order. For a grayscale image, there is one number.

Where the component does not differ between the images, so the PSNR is infinite, the number is inf

But note that the number displayed is also modified by the effect of -max. In particular, with -max, you will never see inf.

This option was new in Netpbm 10.74 (March 2016).

This is meaningful only with -machine.

It specifies the maximum number pnmpsnr will print as a PSNR. If the PSNR is greater than n, pnmpsnr just prints n. n is a decimal floating point number. An infinite PSNR is considered greater than any number.

This is mainly useful to deal with infinite PSNRs. It is often much more convenient to have a program process only numbers than to make it deal with infinity, and often a very large number has the same effect on a program as infinity.

Note that the output is logarithmic, which means you will not see really large but finite numbers. If you specify -max=1000, the only way you will see 1000 in the output is if the PSNR is really infinite. Two images with as many pixels as there are electrons in the universe, differing in only one pixel, and only in the smallest amount representable in the Netpbm format, have a PSNR less than 1000.

This option was new in Netpbm 10.74 (March 2016).

SEE ALSO

pnm(1)

DOCUMENT SOURCE

This manual page was generated by the Netpbm tool 'makeman' from HTML source. The master documentation is at

http://netpbm.sourceforge.net/doc/pnmpsnr.html
23 January 2016 netpbm documentation