Debian Codegraph @

upstream/fedora-rawhide/man1/pnmhisteq.1

raw
1 \
2 .\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
3 .\" Do not hand-hack it! If you have bug fixes or improvements, please find
4 .\" the corresponding HTML page on the Netpbm website, generate a patch
5 .\" against that, and send it to the Netpbm maintainer.
6 .TH "Pnmhisteq User Manual" 0 "22 March 2015" "netpbm documentation"
7
8 .SH NAME
9
10 pnmhisteq - histogram equalize a PNM image
11
12 .UN synopsis
13 .SH SYNOPSIS
14
15 \fBpnmhisteq\fP
16
17 [\fB-gray\fP]
18
19 [\fB-noblack\fP]
20 [\fB-nowhite\fP]
21
22 [\fB-rmap\fP \fIpgmfile\fP]
23
24 [\fB-wmap\fP \fIpgmfile\fP]
25
26 [\fB-verbose\fP]
27
28 [\fIpnmfile\fP]
29
30
31 .UN description
32 .SH DESCRIPTION
33 .PP
34 This program is part of
35 .BR "Netpbm" (1)\c
36 \&.
37 .PP
38 \fBpnmhisteq\fP increases the contrast of a PGM or PPM image
39 through the technique of "histogram equalization."[1]
40 .PP
41 \fBpnmhisteq\fP computes a histogram of the luminosity of the
42 pixels in the image. It then calculates a mapping between each
43 luminosity and a new luminosity such that it spreads out intensity
44 levels around histogram peaks and compresses them at troughs. I.e.
45 it moves pixels around in the histogram so as to make it flat. It
46 applies that mapping to the input image to produce the output image.
47 The effect of this is that the image has equal numbers of pixels at each
48 possible intensity level, which means it uses the available levels of
49 intensity more efficiently and thereby has more visible detail.
50 .PP
51 Mathematically, the luminosity mapping is this: Assume the pixels
52 are sorted by luminosity into \fIB\fP buckets numbered from 0 (lowest
53 luminosity) to \fIB\fP-1. \fIN[i]\fP is the number of pixels in
54 bucket \fIi\fP. \fIT\fP is the total number of pixels (sum of
55 \fIN[i]\fP over all \fIi\fP). \fIW\fP is the luminosity of white.
56 .PP
57 \fBpnmhisteq\fP replaces an input pixel whose luminosity falls into
58 bucket \fIj\fP with one whose luminosity is:
59
60 .nf
61
62 j
63 ---
64 \e
65 > (N[i] / T) * W
66 /
67 ---
68 i=0
69
70 .fi
71 .PP
72 Considering a grayscale image for simplicity, this means that
73 pixels in the most luminous bucket become white. Pixels in the 10th
74 per centile of luminosity become 10% of white.
75 .PP
76 \fBpnmhisteq\fP maps a single luminosity in the input to a single
77 luminosity in the output. That means if pixels A and B both have luminosity
78 \&.2 in the input, and pixel A has luminosity .4 in the output, pixel B also has
79 luminosity .4 in the output. And since the luminosities in the input are not
80 continuous, the luminosities in the output aren't either and \fBpnmhisteq\fP
81 doesn't meet the ideal of having exactly the same number of pixels of each
82 luminosity in the output.
83 .PP
84 If you're processing a related set of images, for example frames of
85 an animation, it's generally best to apply the same luminosity mapping
86 to every frame, since otherwise you'll get distracting frame-to-frame
87 changes in the brightness of objects. \fBpnmhisteq\fP's \fB-wmap\fP
88 option allows you to save, as a PGM image, the luminosity map it
89 computes from an image. The \fB-rmap\fP option causes \fBpnmisteq\fP
90 to use such an image as its luminosity map.
91 .PP
92 So you can run \fBpnmhisteq\fP with \fB-wmap\fP on a composite you
93 created with \fBpamcat\fP of the images you intend to process. Then, you can
94 run \fBpnmisteq\fP with \fB-rmap\fP on each of the individual images, using
95 the luminosity map you generated from the composite.
96 .PP
97 Use \fBpnmhistmap\fP to see the result. Run a color image through
98 \fBppmtopgm\fP first so that you see a histogram of the luminosity instead of
99 histograms of the three color components. It should generally show a flat
100 histogram. But because of the quantization effects described above, you might
101 see high bars interleaved with low bars, with the local average being flat.
102 To see local averages, use the \fB-width\fP option of \fBpnmhistmap\fP.
103
104
105 .UN options
106 .SH OPTIONS
107 .PP
108 In addition to the options common to all programs based on libnetpbm
109 (most notably \fB-quiet\fP, see
110 .UR index.html#commonoptions
111 Common Options
112 .UE
113 \&), \fBpnmhisteq\fP recognizes the following
114 command line options:
115 .PP
116 You can abbreviate any option to its shortest unique prefix.
117
118
119 .TP
120 \fB-gray\fP
121
122
123 When processing a color image, modify only gray pixels (those with
124 identical red, green, and blue values) and include only those pixels in the
125 histogram. This is a special purpose option intended for images where the
126 actual data are gray scale, with color annotations you don't want modified.
127 Weather satellite images that show continent outlines in color are best
128 processed using this option. The option has no effect when the input is a
129 graymap.
130
131 .TP
132 \fB-noblack\fP
133 Do not include black pixels in the equalization. The black pixels in the
134 output are exactly the black pixels in the input and the number of black
135 pixels does not affect the color of any other pixels.
136 .sp
137 Sometimes, black isn't as much a color as a background or annotation for
138 the real colors, so you want to treat it specially this way. Think of a
139 picture of stars, which is nearly all black, but with lots of stars of
140 different brightness. You want to change the brightnesses of the stars to
141 maximize contrast between them, but if you considered the blackness to be
142 significant, all the stars would end up close to full white.
143 .sp
144 This option was new in Netpbm 10.70 (March 2015).
145
146 .TP
147 \fB-nowhite\fP
148 .sp
149 Same as \fB-noblack\fP, but for the white pixels.
150 .sp
151 You can use both \fB-noblack\fP and \fB-nowhite\fP if you like.
152 .sp
153 This option was new in Netpbm 10.70 (March 2015).
154
155 .TP
156 \fB-rmap\fP \fImapfile\fP
157 Process the image using the luminosity map specified by the PGM
158 file \fImapfile\fP.
159
160 The PGM image, usually created by an earlier run of \fBpnmhisteq\fP
161 with the \fB-wmap\fP option, contains a single row with number of
162 columns equal to the maxval (greatest intensity value) of the image
163 plus one. Each pixel in the image is transformed by looking up its
164 luminosity in the corresponding column in the map file (column number
165 = luminosity) and changing it to the value given by that column.
166
167 .TP
168 \fB-wmap\fP \fImapfile\fP
169 Create a PGM file \fImapfile\fP, containing the luminosity map
170 computed from the histogram of the input image. This map file can be
171 read on subsequent runs of \fBpnmhisteq\fP with the \fB-rmap\fP
172 option, allowing a group of images to be processed with an identical
173 map.
174
175 .TP
176 \fB-verbose\fP
177 Prints the histogram and luminosity map on Standard Error.
178
179
180
181 .UN limitations
182 .SH LIMITATIONS
183 .PP
184 Histogram equalization is effective for increasing the visible
185 detail in scientific imagery and in some continuous-tone pictures. It
186 is often too drastic, however, for scanned halftone images, where it
187 does an excellent job of making halftone artifacts apparent. You
188 might want to experiment with \fBpnmnorm\fP and \fBpnmgamma\fP for
189 more subtle contrast enhancement.
190 .PP
191 The luminosity map file supplied by the \fB-rmap\fP option must
192 have the same maxval as the input image. This is always the case when
193 the map file was created by the \fB-wmap\fP option of
194 \fBpnmhisteq\fP. If this restriction causes a problem, simply adjust
195 the maxval of the map with \fBpamdepth\fP to agree with the input
196 image.
197 .PP
198 If the input is a PBM file (on which histogram equalization is an
199 identity operation), the only effect of passing the file through
200 \fBpnmhisteq\fP will be the passage of time.
201
202 .UN seealso
203 .SH SEE ALSO
204 .BR "pnmnorm" (1)\c
205 \&,
206 .BR "pamcat" (1)\c
207 \&,
208 .BR "pamdepth" (1)\c
209 \&,
210 .BR "pnmgamma" (1)\c
211 \&,
212 .BR "pnm" (1)\c
213 \&,
214
215
216 .TP
217 [1]
218 Russ, John C. The Image Processing Handbook. Boca Raton: CRC
219 Press, 1992. Pages 105-110.
220 .SH DOCUMENT SOURCE
221 This manual page was generated by the Netpbm tool 'makeman' from HTML
222 source. The master documentation is at
223 .IP
224 .B http://netpbm.sourceforge.net/doc/pnmhisteq.html
225 .PP