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 However, pamthreshold doesn't check; it just thresholds the first chan‐
28 nel as if it were grayscale samples. So if you feed it e.g. a PPM
29 image, it will work but produce probably useless results.
30
31 The output is a PAM with tuple type BLACKANDWHITE. You can turn this
32 into a PBM (if you need to use it with an older program that doesn't
33 understand PAM, or you can't afford the 8X amount of space that PAM
34 uses for the image) with pamtopnm.
35
36 The output is to Standard Output.
37
38 Another way to convert a grayscale image to black and white is to
39 dither. Dithering is using clustered black and white pixels such that
40 if you step back and look at the picture, you see varying levels of
41 gray. pamditherbw does dithering.
42
43
45 Without any options, pamthreshold uses an iterative algorithm found in
46 the wikipedia ⟨http://www.wikipedia.org/⟩ article
47 Thresholding (image processing)
48 ⟨http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29⟩ to
49 compute the thresholding value. ( this version
50 ⟨http://en.wikipedia.org/w/index.php?title=Thresholding_%28image_processing%29&oldid=132306976⟩
51 of the Wikipedia article was current at the time of this writing). It
52 uses this threshold to globally threshold the image. This should work
53 well for most images. The program issues a message telling you what
54 threshold it used. (Netpbm messages go to Standard Error, and you can
55 turn them off with the Netpbm common option -quiet).
56
57
58
59
60 -simple
61 This selects simple or global thresholding, i.e. pamthreshold
62 compares every pixel to the threshold you specify with -thresh‐
63 old. Those with a brightness greater than or equal to the
64 threshold become white; others become black. This works well
65 for black and white text pages scanned with a flatbed scanner
66 and is faster than the default method that iteratively deter‐
67 mines the thresholding value first.
68
69
70 -local=widthxheight
71 This selects local adaptive thresholding (also known as dynamic
72 thresholding) using the neighborhood of width and height around
73 every pixel. pamthreshold computes the threshold individually
74 for each pixel of the image. This can accommodate changing
75 lighting conditions in the image. Depending on the size of the
76 neighborhood this can be quite slow.
77
78
79 -dual=widthxheight
80 This selects a dual thresholding algorithm using a global
81 threshold for low contrast neighborhoods and local thresholding
82 otherwise. This can preserve larger back- respectively fore‐
83 ground areas than local adaptive thresholding. This algorithm
84 was proposed in the paper "An Approach To Licence Plate Recogni‐
85 tion" by J.R. Parker and Pavol Federl.
86
87
88 -threshold=threshold
89 This sets the thresholding value for simple or local threshold‐
90 ing. The value is a floating point number in the range [0, 1]
91 directly proportional to the Netpbm sample values, , where 0
92 corresponds to black and 1 to the maxval of the image.
93
94 If you don't specify this option, pamthreshold uses a threshold
95 of 0.5. Without -simple or -local this option is meaningless.
96
97 The meaning of the threshold depends upon the kind of threshold‐
98 ing you do (as determined by other options). Roughly, pixels
99 brighter than the threshold become white in the output while
100 others become black.
101
102
103 -contrast=threshold
104 This sets the threshold to determine if a neighborhood has low
105 contrast or not for dual thresholding. The value is a floating
106 point number in the range [0, 1].
107
108 If you don't specify this option, pamthreshold uses a contrast
109 threshold of 0.05. Without -dual this option is meaningless.
110
111
112
113
114
116 pamditherbw(1), ppmtopgm(1), pamtopnm(1), pam(1)
117
118
120 pamthreshold was new in Netpbm 10.34 (June 2006).
121
122
124 pamthreshold is Copyright © 2006 by Erik Auerswald and released
125 under the GPL(1).
126
127
128
129netpbm documentation 06 June 2007 Pamthreshold User Manual(0)