1Pnmhisteq User Manual(0)                              Pnmhisteq User Manual(0)
2
3
4

NAME

6       pnmhisteq - histogram equalize a PNM image
7
8

SYNOPSIS

10       pnmhisteq
11
12       [-gray]
13
14       [-noblack] [-nowhite]
15
16       [-rmap pgmfile]
17
18       [-wmap pgmfile]
19
20       [-verbose]
21
22       [pnmfile]
23
24
25

DESCRIPTION

27       This program is part of Netpbm(1).
28
29       pnmhisteq  increases  the  contrast  of  a PGM or PPM image through the
30       technique of "histogram equalization."[1]
31
32       pnmhisteq computes a histogram of the luminosity of the pixels  in  the
33       image.   It then calculates a mapping between each luminosity and a new
34       luminosity such that it spreads out intensity levels  around  histogram
35       peaks  and compresses them at troughs.  I.e.  it moves pixels around in
36       the histogram so as to make it flat.  It applies that  mapping  to  the
37       input  image  to  produce the output image.  The effect of this is that
38       the image has equal numbers of pixels at each possible intensity level,
39       which  means it uses the available levels of intensity more efficiently
40       and thereby has more visible detail.
41
42       Mathematically, the luminosity mapping is this: Assume the  pixels  are
43       sorted by luminosity into B buckets numbered from 0 (lowest luminosity)
44       to B-1.  N[i] is the number of pixels in bucket i.  T is the total num‐
45       ber of pixels (sum of N[i] over all i).  W is the luminosity of white.
46
47       pnmhisteq  replaces an input pixel whose luminosity falls into bucket j
48       with one whose luminosity is:
49
50
51             j
52            ---
53            \
54             > (N[i] / T) * W
55            /
56            ---
57            i=0
58
59
60       Considering a grayscale image for simplicity, this means that pixels in
61       the  most luminous bucket become white.  Pixels in the 10th per centile
62       of luminosity become 10% of white.
63
64       pnmhisteq maps a single luminosity in the input to a single  luminosity
65       in the output.  That means if pixels A and B both have luminosity .2 in
66       the input, and pixel A has luminosity .4 in the output,  pixel  B  also
67       has luminosity .4 in the output.  And since the luminosities in the in‐
68       put are not continuous, the luminosities in the  output  aren't  either
69       and  pnmhisteq doesn't meet the ideal of having exactly the same number
70       of pixels of each luminosity in the output.
71
72       If you're processing a related set of images, for example frames of  an
73       animation,  it's generally best to apply the same luminosity mapping to
74       every frame, since  otherwise  you'll  get  distracting  frame-to-frame
75       changes  in the brightness of objects.  pnmhisteq's -wmap option allows
76       you to save, as a PGM image, the luminosity map it computes from an im‐
77       age.   The -rmap option causes pnmisteq to use such an image as its lu‐
78       minosity map.
79
80       So you can run pnmhisteq with -wmap on a composite you created with pn‐
81       mcat  of  the images you intend to process.  Then, you can run pnmisteq
82       with -rmap on each of the individual images, using the  luminosity  map
83       you generated from the composite.
84
85       Use  pnmhistmap  to see the result.  Run a color image through ppmtopgm
86       first so that you see a histogram of the  luminosity  instead  of  his‐
87       tograms of the three color components.  It should generally show a flat
88       histogram.  But because of the quantization  effects  described  above,
89       you might see high bars interleaved with low bars, with the local aver‐
90       age being flat.  To see local averages, use the -width  option  of  pn‐
91       mhistmap.
92
93
94

OPTIONS

96       In  addition  to  the options common to all programs based on libnetpbm
97       (most notably -quiet, see
98        Common Options ⟨index.html#commonoptions⟩ ), pnmhisteq recognizes  the
99       following command line options:
100
101       You can abbreviate any option to its shortest unique prefix.
102
103
104
105       -gray  When  processing  a  color  image,  only gray pixels (those with
106              identical red, green, and blue values) are included in the  his‐
107              togram and modified in the output image.  This is a special pur‐
108              pose option intended for images where the actual data  are  gray
109              scale,  with color annotations you don't want modified.  Weather
110              satellite images that show continent outlines in color are  best
111              processed  using this option.  The option has no effect when the
112              input is a graymap.
113
114
115       -noblack
116              Do not include black pixels in the equalization.  The black pix‐
117              els  in the output are exactly the black pixels in the input and
118              the number of black pixels does not  affect  the  color  of  any
119              other pixels.
120
121              Sometimes,  black isn't as much a color as a background or anno‐
122              tation for the real colors, so you want to  treat  it  specially
123              this  way.   Think  of  a  picture of stars, which is nearly all
124              black, but with lots of stars of different brightness.  You want
125              to change the brightnesses of the stars to maximize contrast be‐
126              tween them, but if you considered the blackness to  be  signifi‐
127              cant, all the stars would end up close to full white.
128
129              This option was new in Netpbm 10.70 (March 2015).
130
131
132       -nowhite
133
134              Same as -noblack, but for the white pixels.
135
136              This option was new in Netpbm 10.70 (March 2015).
137
138
139       -rmap mapfile
140              Process  the image using the luminosity map specified by the PGM
141              file mapfile.
142
143              The PGM image, usually created by an earlier  run  of  pnmhisteq
144              with the -wmap option, contains a single row with number of col‐
145              umns equal to the maxval (greatest intensity value) of the image
146              plus  one.  Each pixel in the image is transformed by looking up
147              its luminosity in the corresponding column in the map file (col‐
148              umn  number  = luminosity) and changing it to the value given by
149              that column.
150
151
152       -wmap mapfile
153              Creates a PGM file mapfile, containing the luminosity  map  com‐
154              puted  from the histogram of the input image.  This map file can
155              be read on subsequent runs of pnmhisteq with the  -rmap  option,
156              allowing  a  group  of  images to be processed with an identical
157              map.
158
159
160       -verbose
161              Prints the histogram and luminosity map on Standard Error.
162
163
164
165

LIMITATIONS

167       Histogram equalization is effective for increasing the  visible  detail
168       in  scientific imagery and in some continuous-tone pictures.  It is of‐
169       ten too drastic, however, for scanned halftone images, where it does an
170       excellent job of making halftone artifacts apparent.  You might want to
171       experiment with pnmnorm and pnmgamma for more subtle contrast  enhance‐
172       ment.
173
174       The luminosity map file supplied by the -rmap option must have the same
175       maxval as the input image.  This is always the case when the  map  file
176       was  created  by  the  -wmap  option of pnmhisteq.  If this restriction
177       causes a problem, simply adjust the maxval of the map with pamdepth  to
178       agree with the input image.
179
180       If the input is a PBM file (on which histogram equalization is an iden‐
181       tity operation), the only effect of passing the file through  pnmhisteq
182       will be the passage of time.
183
184

SEE ALSO

186       pnmnorm(1), pnmcat(1), pamdepth(1), pnmgamma(1), pnm(1),
187
188
189
190       [1]    Russ,  John  C.  The Image Processing Handbook.  Boca Raton: CRC
191              Press, 1992.  Pages 105-110.
192

DOCUMENT SOURCE

194       This manual page was generated by the Netpbm tool 'makeman'  from  HTML
195       source.  The master documentation is at
196
197              http://netpbm.sourceforge.net/doc/pnmhisteq.html
198
199netpbm documentation             22 March 2015        Pnmhisteq User Manual(0)
Impressum