1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD><TITLE>Pnmpsnr User Manual</TITLE></HEAD>
<BODY>
<H1>pnmpsnr</H1>
Updated: 06 January 2018
<BR>
<A HREF="#index">Table Of Contents</A>
<H2>NAME</H2>
pnmpsnr - compute the difference between two images (the PSNR)
<H2 id="synopsis">SYNOPSIS</H2>
<B>pnmpsnr</B>
[<I>pnmfile1</I>]
[<I>pnmfile2</I>]
[<b>-rgb</b>]
[<b>-machine</b>]
[<b>-max=</b><i>n</i>]
[<b>-target=</b><i>n</i>]
[<b>-target1=</b><i>n</i>]
[<b>-target2=</b><i>n</i>]
[<b>-target3=</b><i>n</i>]
<P>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.
<H2 id="description">DESCRIPTION</H2>
<p>This program is part of <a href="index.html">Netpbm</a>.
<p><b>pnmpsnr</b> 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.
<p><b>pnmpsnr</b> either prints these values or compares them to thresholds
you specify.
<P>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.
<P>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].
<P>The maximum mean square difference is identically 1.
<P>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.
<p>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.
<P>If the inputs are PBM or PGM, <B>pnmpsnr</B> 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.
<p>By default, the program prints the PSNRs to Standard Output in
human-friendly form.
<p>With the <b>-machine</b> option, the program prints the PSNRs, but
in machine-friendly form.
<p>With a <b>-target</b>[<i>x</i>] option, the program just prints
"match" or "nomatch", depending on whether the PSNRs
exceed targets you specify.
<p><b>pnmpsnr</b> reports the PSNR either in human-friendly form or in
machine-friendly form (see <b>-machine</b>).
<H2 id="options">OPTIONS</H2>
<DL COMPACT>
<DT><B>-rgb</B>
<DD>This option causes <b>pnmpsnr</b> 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.
<p>This option was new in Netpbm 10.71 (June 2015).
<DT><B>-machine</B>
<DD>This option causes <b>pnmpsnr</b> to report the PSNRs in machine-friendly
form, so another program can easily use the information.
<P>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 <b>-rgb</b>),
they are in the order Y, Cb, Cr. For the RGB color space (<b>-rgb</b>), they
are in R, G, B order. For a monotone image, there is one number.
<p>Where the component does not differ between the images, so the PSNR is
infinite, the number is <b>inf</b>
<p>But note that the number displayed is also modified by the effect of
<b>-max</b>. In particular, with <b>-max</b>, you will never see <b>inf</b>.
<p>This option has no effect when you also specify <b>-target</b>[<i>n</i>].
<p>This option was new in Netpbm 10.74 (March 2016).
<dt><b>-max=</b><i>n</i>
<dd>This is meaningful only with <b>-machine</b>.
<p>It specifies the maximum number <b>pnmpsnr</b> will print as a PSNR.
If the PSNR is greater than <i>n</i>, <b>pnmpsnr</b> just prints <i>n</i>.
<i>n</i> is a decimal floating point number. An infinite PSNR is considered
greater than any number.
<p>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.
<p>Note that the output is logarithmic, which means you will not see really
large but finite numbers. If you specify <b>-max=1000</b>, 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.
<p>This option was new in Netpbm 10.74 (March 2016).
<dt><b>-target</b>=<i>n</i>
<dd>This option causes <b>pnmpsnr</b> to run in comparison mode - rather than
print the PSNRs, it just tells you whether the PSNRs exceed
<i>n</i> (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 <i>n</i>, the program prints "match" to Standard Output.
Otherwise, it prints "nomatch".
<p>If you also specify any of <b>-target1</b>, <b>-target2</b>, or
<b>-target3</b>, and the images are color, <b>pnmpsnr</b> ignores
<b>-target</b>.
<p>This is mainly useful for use in a program. If you're
running <b>pnmpsnr</b> manually, you could just run <b>pnmpsnr</b>
without <b>-target</b> and compare the PSNRs to your targets yourself.
<p>This option was new in Netpbm 10.82 (March 2018).
<dt><b>-target</b>{<b>1</b>,<b>2</b>,<b>3</b>}=<i>n</i>
<dd>
Like <b>-target</b>, these options cause <b>pnmpsnr</b> to run in comparison
mode. But they provide separate targets for the individual color component
PSNRs. <b>-target1</b>, <b>target-2</b>, and <b>-target3</b> are for either
the Y, Cb, and Cr components, respectively, or the red, green, and blue
components, respectively, depending upon whether you specified <b>-rgb</b>.
<p>If you don't specify the corresponding <b>-target</b><i>n</i> option for a
component, <b>pnmpsnr</b> ignores the PSNR of that component in deciding
whether the images match.
<p>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 <em>also</em>
specify <b>-target</b>, and the image is PBM or PGM, the program fails.
<p>Note that the options are defined so that you could code a
<b>pnmpsnr</b> 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.
<p>These options were new in Netpbm 10.82 (March 2018).
</dl>
<H2 id="seealso">SEE ALSO</H2>
<B><A HREF="pnm.html">pnm</A></B>
<HR>
<H2 id="index">Table Of Contents</H2>
<UL>
<LI><A HREF="#synopsis">SYNOPSIS</A>
<LI><A HREF="#description">DESCRIPTION</A>
<LI><A HREF="#options">OPTIONS</A>
<LI><A HREF="#seealso">SEE ALSO</A>
</UL>
</BODY>
</HTML>
|