1Pamthreshold User Manual(0) Pamthreshold User Manual(0)
2
3
4
6 pamthreshold - threshold grayscale image to black and white
7
8
10 pamthreshold [-simple] [-local=widthxheight] [-dual=widthxheight]
11 [-threshold=threshold] [-contrast=threshold] [inputpamfile]
12
13 Minimum unique abbreviations of options are acceptable. You may use
14 double hyphens instead of a single hyphen to denote options. You may
15 use white space in place of the equals sign to separate an option name
16 from its value.
17
18
20 This program is part of Netpbm(1).
21
22 pamthreshold thresholds a grayscale image. Thresholding means dividing
23 the image into background and foreground by comparing every pixel to a
24 thresholding value.
25
26 The input should be a PGM image or a PAM image of tuple type GRAYSCALE
27 or GRAYSCALE_ALPHA. However, pamthreshold doesn't check; it just
28 thresholds the first channel as if it were grayscale samples and if
29 there is a second channel, processes it as if it is a transparency
30 (alpha) channel. So if you feed it e.g. a PPM image, it will work but
31 produce probably useless results.
32
33 The output is a PAM with tuple type BLACKANDWHITE or BLACKAND‐
34 WHITE_ALPHA, depending on whether the input has a transparency channel.
35 You can turn this into a PBM (if you need to use it with an older pro‐
36 gram that doesn't understand PAM, or you can't afford the 8X amount of
37 space that PAM uses for the image) with pamtopnm.
38
39 The output is to Standard Output.
40
41 When the input has a transparency channel, pamthreshold includes a
42 transparency channel in the output. Since the output has maxval 1, the
43 transparency channel can indicate only fully transparent or fully
44 opaque. pamthreshold make it fully transparent where the input is more
45 than half transparent and fully opaque where it isn't.
46
47 The transparency function was new in Netpbm 10.43 (June 2008). Before
48 that, pamthreshold ignores any transparency channel in the input.
49
50 Another way to convert a grayscale image to black and white is to
51 dither. Dithering is using clustered black and white pixels such that
52 if you step back and look at the picture, you see varying levels of
53 gray. pamditherbw does dithering.
54
55
57 Without any options, pamthreshold uses a method based on the iterative
58 algorithm found in the wikipedia ⟨http://www.wikipedia.org/⟩ article
59 Thresholding (image processing)
60 ⟨http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29⟩ to
61 compute the thresholding value. ( this version
62 ⟨http://en.wikipedia.org/w/index.php?title=Thresholding_%28image_processing%29&oldid=132306976⟩
63 of the Wikipedia article was current at the time of this writing). It
64 uses this threshold to globally threshold the image. This should work
65 well for most images. The program issues a message telling you what
66 threshold it used. (Netpbm messages go to Standard Error, and you can
67 turn them off with the Netpbm common option -quiet).
68
69 Options -simple, -local, and -dual select other methods.
70
71
72
73
74 -simple
75 This selects simple or global thresholding, i.e. pamthreshold
76 compares every pixel to the threshold you specify with -thresh‐
77 old. Those with a brightness greater than or equal to the
78 threshold become white; others become black. This works well
79 for black and white text pages scanned with a flatbed scanner
80 and is faster than the default method that iteratively deter‐
81 mines the thresholding value first.
82
83
84 -local=widthxheight
85 This selects local adaptive thresholding (also known as dynamic
86 thresholding) using the neighborhood which is the square width
87 pixels wide and height pixels high centered on the pixel in
88 question. pamthreshold computes the threshold individually for
89 each pixel of the image. This can accommodate changing lighting
90 conditions in the image. Depending on the size of the neighbor‐
91 hood this can be quite slow.
92
93
94 -dual=widthxheight
95 This selects a dual thresholding algorithm using a global
96 threshold for low contrast neighborhoods and local thresholding
97 otherwise. This can preserve larger back- respectively fore‐
98 ground areas than local adaptive thresholding. This algorithm
99 was proposed in the paper "An Approach To Licence Plate Recogni‐
100 tion" by J.R. Parker and Pavol Federl.
101
102
103 -threshold=threshold
104 This sets the thresholding value for simple or local threshold‐
105 ing. The value is a floating point number in the range [0, 1]
106 directly proportional to the Netpbm sample values, where 0 cor‐
107 responds to black and 1 to the maxval of the image.
108
109 If you don't specify this option, pamthreshold uses a threshold
110 of 0.5.
111
112 Without -simple, -local, or -dual, this option is meaningless.
113
114 The meaning of the threshold depends upon the kind of threshold‐
115 ing you do (as determined by other options). Roughly, pixels at
116 least as bright as the threshold become white in the output
117 while others become black.
118
119
120 -contrast=threshold
121 This sets the threshold to determine if a neighborhood has low
122 contrast or not for dual thresholding. The value is a floating
123 point number in the range [0, 1].
124
125 If you don't specify this option, pamthreshold uses a contrast
126 threshold of 0.05. Without -dual this option is meaningless.
127
128
129
130
131
133 pamditherbw(1), ppmtopgm(1), pamtopnm(1), pam(1)
134
135
137 pamthreshold was new in Netpbm 10.34 (June 2006).
138
139
141 pamthreshold is Copyright © 2006 by Erik Auerswald and released under
142 the GPL(1).
143
145 This manual page was generated by the Netpbm tool 'makeman' from HTML
146 source. The master documentation is at
147
148 http://netpbm.sourceforge.net/doc/pamthreshold.html
149
150netpbm documentation 06 June 2007 Pamthreshold User Manual(0)