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       [-rmap pgmfile]
15
16       [-wmap pgmfile]
17
18       [-verbose]
19
20       [pnmfile]
21
22
23

DESCRIPTION

25       This program is part of Netpbm(1).
26
27       pnmhisteq  increases  the  contrast  of  a PGM or PPM image through the
28       technique of 'histogram equalization.'[1]
29
30       pnmhisteq computes a histogram of the luminosity of the pixels  in  the
31       image.   It then calculates a mapping between each luminosity and a new
32       luminosity such that it spreads out intensity levels  around  histogram
33       peaks  and compresses them at troughs.  I.e.  it moves pixels around in
34       the histogram so as to make it flat.  It applies that  mapping  to  the
35       input  image  to  produce the output image.  The effect of this is that
36       the image has equal numbers of pixels at each possible intensity level,
37       which  means it uses the available levels of intensity more efficiently
38       and thereby has more visible detail.
39
40       Mathematically, the luminosity mapping is this: Assume the  pixels  are
41       sorted by luminosity into B buckets numbered from 0 (lowest luminosity)
42       to B-1.  N[i] is the number of pixels in bucket i.  T is the total num‐
43       ber of pixels (sum of N[i] over all i).  W is the luminosity of white.
44
45       pnmhisteq  replaces an input pixel whose luminosity falls into bucket j
46       with one whose luminosity is:
47
48
49             j
50            ---
51                  > (N[i] / T) * W
52            /
53            ---
54            i=0
55
56       Considering a grayscale image for simplicity, this means that pixels in
57       the  most luminous bucket become white.  Pixels in the 10th per centile
58       of luminosity become 10% of white.
59
60       If you're processing a related set of images, for example frames of  an
61       animation,  it's generally best to apply the same luminosity mapping to
62       every frame, since  otherwise  you'll  get  distracting  frame-to-frame
63       changes  in the brightness of objects.  pnmhisteq's -wmap option allows
64       you to save, as a PGM image, the luminosity map  it  computes  from  an
65       image.   The  -rmap  option causes pnmisteq to use such an image as its
66       luminosity map.
67
68       So you can run pnmhisteq with -wmap on a  composite  you  created  with
69       pnmcat of the images you intend to process.  Then, you can run pnmisteq
70       with -rmap on each of the individual images, using the  luminosity  map
71       you generated from the composite.
72
73
74

OPTIONS

76       You can abbreviate any option to its shortest unique prefix.
77
78
79
80       -gray  When  processing  a  color  image,  only gray pixels (those with
81              identical red, green, and blue values) are included in the  his‐
82              togram and modified in the output image.  This is a special pur‐
83              pose option intended for images where the actual data  are  gray
84              scale,  with color annotations you don't want modified.  Weather
85              satellite images that show continent outlines in color are  best
86              processed  using this option.  The option has no effect when the
87              input is a graymap.
88
89
90       -rmap mapfile
91              Process the image using the luminosity map specified by the  PGM
92              file mapfile.
93
94              The  PGM  image,  usually created by an earlier run of pnmhisteq
95              with the -wmap option, contains a single row with number of col‐
96              umns equal to the maxval (greatest intensity value) of the image
97              plus one.  Each pixel in the image is transformed by looking  up
98              its luminosity in the corresponding column in the map file (col‐
99              umn number = luminosity) and changing it to the value  given  by
100              that column.
101
102
103       -wmap mapfile
104              Creates  a  PGM file mapfile, containing the luminosity map com‐
105              puted from the histogram of the input image.  This map file  can
106              be  read  on subsequent runs of pnmhisteq with the -rmap option,
107              allowing a group of images to be  processed  with  an  identical
108              map.
109
110
111       -verbose
112              Prints the histogram and luminosity map on Standard Error.
113
114
115
116

LIMITATIONS

118       Histogram  equalization  is effective for increasing the visible detail
119       in scientific imagery and in  some  continuous-tone  pictures.   It  is
120       often  too drastic, however, for scanned halftone images, where it does
121       an excellent job of making halftone artifacts apparent.  You might want
122       to  experiment  with  pnmnorm  and  pnmgamma  for  more subtle contrast
123       enhancement.
124
125       The luminosity map file supplied by the -rmap option must have the same
126       maxval  as  the input image.  This is always the case when the map file
127       was created by the -wmap option  of  pnmhisteq.   If  this  restriction
128       causes  a problem, simply adjust the maxval of the map with pamdepth to
129       agree with the input image.
130
131       If the input is a PBM file (on which histogram equalization is an iden‐
132       tity  operation), the only effect of passing the file through pnmhisteq
133       will be the passage of time.
134
135

SEE ALSO

137       pnmnorm(1), pnmcat(1), pamdepth(1), pnmgamma(1), pnm(1),
138
139
140
141       [1]    Russ, John C.  The Image Processing Handbook.  Boca  Raton:  CRC
142              Press, 1992.  Pages 105-110.
143
144
145
146

AUTHOR

148       Copyright  (C)  1995  by  John  Walker (kelvin@fourmilab.ch).  WWW home
149       page: http://www.fourmilab.ch/http://www.fourmilab.ch/
150
151       Permission to use, copy, modify, and distribute this software  and  its
152       documentation  for any purpose and without fee is hereby granted, with‐
153       out any conditions or restrictions.  This software is provided 'as  is'
154       without express or implied warranty.
155
156
157
158netpbm documentation           10 September 2005      Pnmhisteq User Manual(0)
Impressum