1Pnmnorm User Manual(0) Pnmnorm User Manual(0)
2
3
4
6 pnmnorm - normalize the contrast in a Netbpm image
7
8
10 pnmnorm
11
12 [-bpercent=N | -bvalue=N]
13
14 [-wpercent=N | -wvalue=N]
15
16 [-maxexpand]
17
18 [-keephues]
19
20 [-luminosity | -colorvalue | -saturation]
21
22 [ppmfile]
23
24 All options can be abbreviated to their shortest unique prefix. You
25 may use two hyphens instead of one to designate an option. You may use
26 either white space or an equals sign between an option name and its
27 value.
28
29
31 This program is part of Netpbm(1).
32
33 pnmnorm reads a PNM image (PBM, PGM, or PPM). It normalizes the con‐
34 trast by forcing the brightest pixels to white, the darkest pixels to
35 black, and linearly rescaling the ones in between; and produces the
36 same kind of file as output. This is pretty useless for a PBM image.
37
38 The program first determines a mapping of old brightness to new bright‐
39 ness. For each possible brightness of a pixel, the program determines
40 a corresponding brightness for the output image.
41
42 Then for each pixel in the image, the program computes a color which
43 has the desired output brightness and puts that in the output. With a
44 color image, it is not always possible to compute such a color and
45 retain any semblance of the original hue, so the brightest and dimmest
46 pixels may only approximate the desired brightness.
47
48 For a PPM image, you have a choice of three different ways to define
49 brightness:
50
51
52 · luminosity
53
54 · color value
55
56 · saturation
57
58
59 In the case of saturation, 'brightness' is pretty much a mis‐
60 nomer, but you can use the brightness analogy to see what it
61 does. In the analogy, bright means saturated and dark means
62 unsaturated.
63
64 Note that all of these are different from separately normalizing the
65 individual color components.
66
67 An alternative way to spread out the brightnesses in an image is
68 pnmhisteq. pnmhisteq stretches the brightest pixels to white and the
69 darkest pixels to black, but rather than linearly adjusting the ones in
70 between, it adjusts them so that there are an equal number of pixels of
71 each brightness throughout the range. This gives you more contrast
72 than pnmnorm does, but can considerably change the picture in exchange.
73
74
75
77 By default, the darkest 2 percent of all pixels are mapped to black,
78 and the brightest 1 percent are mapped to white. You can override
79 these percentages by using the -bpercent and -wpercent options, or you
80 can specify the exact pixel values to be mapped by using the -bvalue
81 and -wvalue options. You can get appropriate numbers for the options
82 from ppmhist. If you just want to enhance the contrast, then choose
83 values at elbows in the histogram; e.g. if value 29 represents 3% of
84 the image but value 30 represents 20%, choose 30 for bvalue. If you
85 want to brighten the image, then set bvalue to 0 and just fiddle with
86 wvalue; similarly, to darken the image, set wvalue to maxval and play
87 with bvalue.
88
89 If you specify both -bvalue and -bpercent, pnmnorm uses the one that
90 produces the least change. The same goes for -wvalue and -wpercent.
91 (In Netpbm 10.26 (January 2005), the -bvalue/-wvalue takes precedence,
92 and before that, it's a syntax error to specify both).
93
94 If you want to maximize the change instead of minimizing it, just cas‐
95 cade two runs of pnmnorm, specifying values for the first and percent‐
96 ages for the second.
97
98 -bpercent and -wpercent values are floating point decimal. Zero is
99 valid and is the same as -bvalue=0 or -wvalue=maxval, respectively.
100
101 Because there are whole numbers of pixels at each brightness, pnmnorm
102 obviously can't guarantee the exact per centage, so it arranges that at
103 least the per centage of pixels you specify get remapped as promised.
104
105 It is possible for your -bpercent or -wpercent to overlap your -wvalue
106 or -bvalue, respectively. For example, you say -bpercent=20 and
107 -wvalue=100 for an image in which only 10 per cent of the pixels are
108 darker than 100. In that case, pnmnorm adjusts the per centile value
109 as required. In the example, it uses 99 as the black value (like
110 -bvalue=99).
111
112 It is also possible for your -bpercent and -wpercent options to select
113 the same brightness value for the stretch-to-white and stretch-to-black
114 value because of the fact that pnmnorm can't subdivide a histogram
115 cell. E.g. if an image is all brightness 100, then no matter what
116 -bpercent and -wpercent values you choose, it's the same as saying
117 -bvalue=100 -wvalue=100. In that case, pnmnorm changes one of the val‐
118 ues by 1 to make it legal. In the example, pnmnorm would either make
119 the black value 99 or the white value 101.
120
121 Before Netpbm 10.43 (June 2008), pnmnorm fails if the -wpercent and/or
122 -bpercent values specify an overlap.
123
124 The stretch points are further constrained by the -maxexpand option.
125 Sometimes, too much contrast is a bad thing. If your intensities are
126 all concentrated in the middle, -bpercent=2 and -wpercent=1 might mean
127 that an intensity of 60 gets stretched up to 100 and and intensity of
128 40 gets stretched down to zero, for a range expansion of 150% (from a
129 range of 40 to a range of 100). That much stretching means two adja‐
130 cent pixels that used to differ in intensity by 4 units now differ by
131 10, and that might be unsightly.
132
133 So that you can put a limit on the amount of expansion without having
134 to examine the image first, there is the -maxexpand option. It speci‐
135 fies the maximum expansion you will tolerate, as an additional per cen‐
136 tage. In the example above, you could say -maxexpand=50 to say you
137 want the range to expand by at most 50%, regardless of your other
138 options. pnmnorm figures out what intensity to stretch to full inten‐
139 sity and what intensity to stretch to zero intensity as described
140 above, and then raises the former and lowers the latter as needed to
141 limit the expansion to the amount you specified.
142
143 When pnmnorm limits the expansion due to -maxexpand, it tells you about
144 it with a message like this:
145 limiting expansion of 150% to 50%
146
147 In any case, pnmnorm tells you exactly what expansion it's doing, like
148 this:
149
150 remapping 25..75 to 0..100
151
152 Before Netpbm 10.26 (December 2004), it was not valid to specify both
153 -bvalue and -bpercent or -wvalue and -wpercent.
154
155 -maxexpand was new in Netpbm 10.32 (February 2006).
156
157 The -keephues option says to keep each pixel the same hue as it is in
158 the input; just adjust its brightness. You normally want this; the
159 only reason it is not the default behavior is backward compatibility
160 with a design mistake.
161
162 By default, pnmnorm normalizes contrast in each component independently
163 (except that the meaning of the -wpercent and -bpercent options are
164 based on the overall brightnesses of the colors, not each component
165 taken separately). So if you have a color which is intensely red but
166 dimly green, pnmnorm would make the red more intense and the green less
167 intense, so you end up with a different hue than you started with.
168
169 If you specify -keephues, pnmnorm would likely leave this pixel alone,
170 since its overall brightness is medium.
171
172 -keephues can cause clipping, because a certain color may be below a
173 target intensity while one of its components is saturated. Where
174 that's the case, pnmnorm uses the maximum representable intensity for
175 the saturated component and the pixel ends up with less overall inten‐
176 sity, and a different hue, than it is supposed to have.
177
178 This option is meaningless on grayscale images.
179
180 When you don't specify -keephues, the -luminosity, -colorvalue, and
181 -saturation options affect the transfer function (which is the same for
182 all three RGB components), but are meaningless when it comes to apply‐
183 ing the transfer function (since it is applied to each individual RGB
184 component).
185
186 Before Netpbm 9.25 (March 2002), there was no -keephues option.
187
188 -luminosity, -colorvalue, and -saturation determine what property of
189 the pixels pnmnorm normalizes. I.e., what kind of brightness. You
190 cannot specify more than one of these.
191
192 The -luminosity option says to use the luminosity (i.e. the 'Y' in the
193 YUV or YCbCr color space) as the pixel's brightness. The luminosity is
194 a measure of how bright a human eye would find the color, taking into
195 account the fact that the human eye is more sensitive to some RGB com‐
196 ponents than others.
197
198 This option is default.
199
200 This option is meaningless on grayscale images.
201
202 Before Netpbm 10.28 (August 2005), there was no -luminosity option, but
203 its meaning was still the default.
204
205 Before Netpbm 10.28 (August 2005), there was no -colorvalue option.
206
207 The -colorvalue option says to use the color value (i.e. the 'V' in the
208 HSV color space) as the pixel's brightness. The color value is the
209 gamma-adjusted intensity of the most intense RGB component.
210
211 This option is meaningless on grayscale images.
212
213 Before Netpbm 10.28 (August 2005), there was no -colorvalue option.
214
215 The -saturation option says to use the saturation (i.e. the 'S' in the
216 HSV color space) as the pixel's brightness. The saturation is the
217 ratio of the intensity of the most intense RGB component to the differ‐
218 ence between the intensities of the most and least intense RGB compo‐
219 nent (all intensities gamma-adjusted).
220
221 In this case, 'brightness' is more of a metaphor than anything.
222 'bright' means saturated and 'dark' means unsaturated.
223
224 This option is meaningless on grayscale images.
225
226 Before Netpbm 10.28 (August 2005), there was no -colorvalue option.
227
228
229
230
232 pnmhisteq(1), ppmhist(1), pgmhist(1), pnmgamma(1), ppmbrighten(1),
233 ppmdim(1), pnm(1)
234
235
236
237netpbm documentation 6 January 2006 Pnmnorm User Manual(0)