\ .\" This man page was generated by the Netpbm tool 'makeman' from HTML source. .\" Do not hand-hack it! If you have bug fixes or improvements, please find .\" the corresponding HTML page on the Netpbm website, generate a patch .\" against that, and send it to the Netpbm maintainer. .TH "Pnmpsnr User Manual" 0 "06 January 2018" "netpbm documentation" .SH NAME pnmpsnr - compute the difference between two images (the PSNR) .UN synopsis .SH SYNOPSIS \fBpnmpsnr\fP [\fIpnmfile1\fP] [\fIpnmfile2\fP] [\fB-rgb\fP] [\fB-machine\fP] [\fB-max=\fP\fIn\fP] [\fB-target=\fP\fIn\fP] [\fB-target1=\fP\fIn\fP] [\fB-target2=\fP\fIn\fP] [\fB-target3=\fP\fIn\fP] .PP 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. .UN description .SH DESCRIPTION .PP This program is part of .BR "Netpbm" (1)\c \&. .PP \fBpnmpsnr\fP reads two PBM, PGM, or PPM files, or PAM equivalents, as input and computes 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. .PP \fBpnmpsnr\fP either prints these values or compares them to thresholds you specify. .PP 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. .PP 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]. .PP The maximum mean square difference is identically 1. .PP 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. .PP 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. .PP If the inputs are PBM or PGM, \fBpnmpsnr\fP computes the PSNR of the luminance only. Otherwise, it computes three separate PSNRs: either the luminance, and chrominance (Cb and Cr) components of the colors or the red, green, and blue components. .PP By default, the program prints the PSNRs to Standard Output in human-friendly form. .PP With the \fB-machine\fP option, the program prints the PSNRs, but in machine-friendly form. .PP With a \fB-target\fP[\fIx\fP] option, the program just prints \&'match' or 'nomatch', depending on whether the PSNRs exceed targets you specify. .PP \fBpnmpsnr\fP reports the PSNR either in human-friendly form or in machine-friendly form (see \fB-machine\fP). .UN options .SH OPTIONS .PP In addition to the options common to all programs based on libnetpbm (most notably \fB-quiet\fP, see .UR index.html#commonoptions Common Options .UE \&), \fBpnmpsnr\fP recognizes the following command line options: .TP \fB-rgb\fP This option causes \fBpnmpsnr\fP to compare the red, green, and blue components of the color rather than the luminance and chrominance components. It has no effect on a monotone image. .sp This option was new in Netpbm 10.71 (June 2015). .TP \fB-machine\fP This option causes \fBpnmpsnr\fP to report the PSNRs in machine-friendly form, so another program can easily use the information. .sp 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 \fB-rgb\fP), they are in the order Y, Cb, Cr. For the RGB color space (\fB-rgb\fP), they are in R, G, B order. For a monotone image, there is one number. .sp Where the component does not differ between the images, so the PSNR is infinite, the number is \fBinf\fP .sp But note that the number displayed is also modified by the effect of \fB-max\fP. In particular, with \fB-max\fP, you will never see \fBinf\fP. .sp This option has no effect when you also specify \fB-target\fP[\fIn\fP]. .sp This option was new in Netpbm 10.74 (March 2016). .TP \fB-max=\fP\fIn\fP This is meaningful only with \fB-machine\fP. .sp It specifies the maximum number \fBpnmpsnr\fP will print as a PSNR. If the PSNR is greater than \fIn\fP, \fBpnmpsnr\fP just prints \fIn\fP. \fIn\fP is a decimal floating point number. An infinite PSNR is considered greater than any number. .sp 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. .sp Note that the output is logarithmic, which means you will not see really large but finite numbers. If you specify \fB-max=1000\fP, 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. .sp This option was new in Netpbm 10.74 (March 2016). .TP \fB-target\fP=\fIn\fP This option causes \fBpnmpsnr\fP to run in comparison mode - rather than print the PSNRs, it just tells you whether the PSNRs exceed \fIn\fP (a floating point number), i.e. whether the compared images are the same within a given margin of error. If all the computed PSNRs (luminance for a PBM or PGM; luminance and chrominance or red, green, and blue for PPM) exceed \fIn\fP, the program prints 'match' to Standard Output. Otherwise, it prints 'nomatch'. .sp If you also specify any of \fB-target1\fP, \fB-target2\fP, or \fB-target3\fP, and the images are color, \fBpnmpsnr\fP ignores \fB-target\fP. .sp This is mainly useful for use in a program. If you're running \fBpnmpsnr\fP manually, you could just run \fBpnmpsnr\fP without \fB-target\fP and compare the PSNRs to your targets yourself. .sp This option was new in Netpbm 10.82 (March 2018). .TP \fB-target\fP{\fB1\fP,\fB2\fP,\fB3\fP}=\fIn\fP Like \fB-target\fP, these options cause \fBpnmpsnr\fP to run in comparison mode. But they provide separate targets for the individual color component PSNRs. \fB-target1\fP, \fBtarget-2\fP, and \fB-target3\fP are for either the Y, Cb, and Cr components, respectively, or the red, green, and blue components, respectively, depending upon whether you specified \fB-rgb\fP. .sp If you don't specify the corresponding \fB-target\fP\fIn\fP option for a component, \fBpnmpsnr\fP ignores the PSNR of that component in deciding whether the images match. .sp If the image is a PBM or PGM, these options have no effect, except that it stilll selects comparison mode, so if you don't \fIalso\fP specify \fB-target\fP, and the image is PBM or PGM, the program fails. .sp Note that the options are defined so that you could code a \fBpnmpsnr\fP command in a program that works on both color and monotone images, specifying individual PSNR targets for use on the color images and the single target for use on the monotone images. .sp These options were new in Netpbm 10.82 (March 2018). .UN seealso .SH SEE ALSO .BR "pnm" (1)\c \& .SH DOCUMENT SOURCE This manual page was generated by the Netpbm tool 'makeman' from HTML source. The master documentation is at .IP .B http://netpbm.sourceforge.net/doc/pnmpsnr.html .PP