| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN"> |
| 2 |
<html><head><title>Pnmpsnr User Manual</title></head> |
| 3 |
<body> |
| 4 |
<h1>pnmpsnr</h1> |
| 5 |
Updated: 06 January 2018 |
| 6 |
<br> |
| 7 |
<a href="#index">Table Of Contents</a> |
| 8 |
|
| 9 |
<h2>NAME</h2> |
| 10 |
pnmpsnr - compute the difference between two images (the PSNR) |
| 11 |
|
| 12 |
<h2 id="synopsis">SYNOPSIS</h2> |
| 13 |
|
| 14 |
<b>pnmpsnr</b> |
| 15 |
|
| 16 |
[<i>pnmfile1</i>] |
| 17 |
|
| 18 |
[<i>pnmfile2</i>] |
| 19 |
|
| 20 |
[<b>-rgb</b>] |
| 21 |
[<b>-machine</b>] |
| 22 |
[<b>-max=</b><i>n</i>] |
| 23 |
[<b>-target=</b><i>n</i>] |
| 24 |
[<b>-target1=</b><i>n</i>] |
| 25 |
[<b>-target2=</b><i>n</i>] |
| 26 |
[<b>-target3=</b><i>n</i>] |
| 27 |
|
| 28 |
<p>Minimum unique abbreviations of options are acceptable. You may use |
| 29 |
double hyphens instead of single hyphen to denote options. You may use |
| 30 |
white space in place of the equals sign to separate an option name |
| 31 |
from its value. |
| 32 |
|
| 33 |
|
| 34 |
<h2 id="description">DESCRIPTION</h2> |
| 35 |
|
| 36 |
<p>This program is part of <a href="index.html">Netpbm</a>. |
| 37 |
|
| 38 |
<p><b>pnmpsnr</b> reads two PBM, PGM, or PPM files, or PAM equivalents, as |
| 39 |
input and computes the magnitude of difference between the two images as a peak |
| 40 |
signal-to-noise ratio (PSNR) This metric is typically used in image |
| 41 |
compression papers to rate the distortion between original and decoded image. |
| 42 |
|
| 43 |
<p><b>pnmpsnr</b> either prints these values or compares them to thresholds |
| 44 |
you specify. |
| 45 |
|
| 46 |
<p>The PSNR of a given component is the ratio of the maximum mean square |
| 47 |
difference of component values that could exist between the two images (a |
| 48 |
measure of the information content in an image) to the actual mean square |
| 49 |
difference for the two subject images. It is expressed as a decibel value. |
| 50 |
|
| 51 |
<p>The mean square difference of a component for two images is the |
| 52 |
mean square difference of the component value, comparing each pixel |
| 53 |
with the pixel in the same position of the other image. For the |
| 54 |
purposes of this computation, components are normalized to the scale |
| 55 |
[0..1]. |
| 56 |
|
| 57 |
<p>The maximum mean square difference is identically 1. |
| 58 |
|
| 59 |
<p>So the higher the PSNR, the closer the images are. A luminance |
| 60 |
PSNR of 20 means the mean square difference of the luminances of the |
| 61 |
pixels is 100 times less than the maximum possible difference, |
| 62 |
i.e. 0.01. |
| 63 |
|
| 64 |
<p>Note that the word "peak" is a misnomer; there is no maximum involved; the |
| 65 |
metric is a mean. But "peak signal to noise ratio" is for some reason the |
| 66 |
common term for this measurement. |
| 67 |
|
| 68 |
<p>If the inputs are PBM or PGM, <b>pnmpsnr</b> computes the PSNR of the |
| 69 |
luminance only. Otherwise, it computes three separate PSNRs: either the |
| 70 |
luminance, and chrominance (Cb and Cr) components of the colors or the |
| 71 |
red, green, and blue components. |
| 72 |
|
| 73 |
<p>By default, the program prints the PSNRs to Standard Output in |
| 74 |
human-friendly form. |
| 75 |
|
| 76 |
<p>With the <b>-machine</b> option, the program prints the PSNRs, but |
| 77 |
in machine-friendly form. |
| 78 |
|
| 79 |
<p>With a <b>-target</b>[<i>x</i>] option, the program just prints |
| 80 |
"match" or "nomatch", depending on whether the PSNRs |
| 81 |
exceed targets you specify. |
| 82 |
|
| 83 |
<p><b>pnmpsnr</b> reports the PSNR either in human-friendly form or in |
| 84 |
machine-friendly form (see <b>-machine</b>). |
| 85 |
|
| 86 |
|
| 87 |
<h2 id="options">OPTIONS</h2> |
| 88 |
|
| 89 |
<p>In addition to the options common to all programs based on libnetpbm |
| 90 |
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions"> |
| 91 |
Common Options</a>), <b>pnmpsnr</b> recognizes the following |
| 92 |
command line options: |
| 93 |
|
| 94 |
<dl compact> |
| 95 |
<dt><b>-rgb</b> |
| 96 |
|
| 97 |
<dd>This option causes <b>pnmpsnr</b> to compare the red, green, and blue |
| 98 |
components of the color rather than the luminance and chrominance components. |
| 99 |
It has no effect on a monotone image. |
| 100 |
|
| 101 |
<p>This option was new in Netpbm 10.71 (June 2015). |
| 102 |
|
| 103 |
<dt><b>-machine</b> |
| 104 |
|
| 105 |
<dd>This option causes <b>pnmpsnr</b> to report the PSNRs in machine-friendly |
| 106 |
form, so another program can easily use the information. |
| 107 |
|
| 108 |
<p>The output is a single line. It contains one floating point decimal number |
| 109 |
for each color component, with a single space between every two. (This means |
| 110 |
there are either 1 or 3 numbers). For the YCbCr color space (no <b>-rgb</b>), |
| 111 |
they are in the order Y, Cb, Cr. For the RGB color space (<b>-rgb</b>), they |
| 112 |
are in R, G, B order. For a monotone image, there is one number. |
| 113 |
|
| 114 |
<p>Where the component does not differ between the images, so the PSNR is |
| 115 |
infinite, the number is <b>inf</b> |
| 116 |
|
| 117 |
<p>But note that the number displayed is also modified by the effect of |
| 118 |
<b>-max</b>. In particular, with <b>-max</b>, you will never see <b>inf</b>. |
| 119 |
|
| 120 |
<p>This option has no effect when you also specify <b>-target</b>[<i>n</i>]. |
| 121 |
|
| 122 |
<p>This option was new in Netpbm 10.74 (March 2016). |
| 123 |
|
| 124 |
<dt><b>-max=</b><i>n</i> |
| 125 |
|
| 126 |
<dd>This is meaningful only with <b>-machine</b>. |
| 127 |
|
| 128 |
<p>It specifies the maximum number <b>pnmpsnr</b> will print as a PSNR. |
| 129 |
If the PSNR is greater than <i>n</i>, <b>pnmpsnr</b> just prints <i>n</i>. |
| 130 |
<i>n</i> is a decimal floating point number. An infinite PSNR is considered |
| 131 |
greater than any number. |
| 132 |
|
| 133 |
<p>This is mainly useful to deal with infinite PSNRs. It is often much more |
| 134 |
convenient to have a program process only numbers than to make it deal with |
| 135 |
infinity, and often a very large number has the same effect on a program as |
| 136 |
infinity. |
| 137 |
|
| 138 |
<p>Note that the output is logarithmic, which means you will not see really |
| 139 |
large but finite numbers. If you specify <b>-max=1000</b>, the only way you |
| 140 |
will see 1000 in the output is if the PSNR is really infinite. Two images |
| 141 |
with as many pixels as there are electrons in the universe, differing in only |
| 142 |
one pixel, and only in the smallest amount representable in the Netpbm format, |
| 143 |
have a PSNR less than 1000. |
| 144 |
|
| 145 |
<p>This option was new in Netpbm 10.74 (March 2016). |
| 146 |
|
| 147 |
<dt><b>-target</b>=<i>n</i> |
| 148 |
|
| 149 |
<dd>This option causes <b>pnmpsnr</b> to run in comparison mode - rather than |
| 150 |
print the PSNRs, it just tells you whether the PSNRs exceed |
| 151 |
<i>n</i> (a floating point number), i.e. whether the compared images are the |
| 152 |
same within a given margin of error. If all the computed PSNRs (luminance for |
| 153 |
a PBM or PGM; luminance and chrominance or red, green, and blue for PPM) |
| 154 |
exceed <i>n</i>, the program prints "match" to Standard Output. |
| 155 |
Otherwise, it prints "nomatch". |
| 156 |
|
| 157 |
<p>If you also specify any of <b>-target1</b>, <b>-target2</b>, or |
| 158 |
<b>-target3</b>, and the images are color, <b>pnmpsnr</b> ignores |
| 159 |
<b>-target</b>. |
| 160 |
|
| 161 |
<p>This is mainly useful for use in a program. If you're |
| 162 |
running <b>pnmpsnr</b> manually, you could just run <b>pnmpsnr</b> |
| 163 |
without <b>-target</b> and compare the PSNRs to your targets yourself. |
| 164 |
|
| 165 |
<p>This option was new in Netpbm 10.82 (March 2018). |
| 166 |
|
| 167 |
<dt><b>-target</b>{<b>1</b>,<b>2</b>,<b>3</b>}=<i>n</i> |
| 168 |
<dd> |
| 169 |
Like <b>-target</b>, these options cause <b>pnmpsnr</b> to run in comparison |
| 170 |
mode. But they provide separate targets for the individual color component |
| 171 |
PSNRs. <b>-target1</b>, <b>target-2</b>, and <b>-target3</b> are for either |
| 172 |
the Y, Cb, and Cr components, respectively, or the red, green, and blue |
| 173 |
components, respectively, depending upon whether you specified <b>-rgb</b>. |
| 174 |
|
| 175 |
<p>If you don't specify the corresponding <b>-target</b><i>n</i> option for a |
| 176 |
component, <b>pnmpsnr</b> ignores the PSNR of that component in deciding |
| 177 |
whether the images match. |
| 178 |
|
| 179 |
<p>If the image is a PBM or PGM, these options have no effect, except that it |
| 180 |
stilll selects comparison mode, so if you don't <em>also</em> |
| 181 |
specify <b>-target</b>, and the image is PBM or PGM, the program fails. |
| 182 |
|
| 183 |
<p>Note that the options are defined so that you could code a |
| 184 |
<b>pnmpsnr</b> command in a program that works on both color and monotone |
| 185 |
images, specifying individual PSNR targets for use on the color images and the |
| 186 |
single target for use on the monotone images. |
| 187 |
|
| 188 |
<p>These options were new in Netpbm 10.82 (March 2018). |
| 189 |
|
| 190 |
</dl> |
| 191 |
|
| 192 |
|
| 193 |
<h2 id="seealso">SEE ALSO</h2> |
| 194 |
|
| 195 |
<b><a href="pnm.html">pnm</a></b> |
| 196 |
|
| 197 |
<hr> |
| 198 |
<h2 id="index">Table Of Contents</h2> |
| 199 |
<ul> |
| 200 |
<li><a href="#synopsis">SYNOPSIS</a> |
| 201 |
<li><a href="#description">DESCRIPTION</a> |
| 202 |
<li><a href="#options">OPTIONS</a> |
| 203 |
<li><a href="#seealso">SEE ALSO</a> |
| 204 |
</ul> |
| 205 |
</body> |
| 206 |
</html> |