summaryrefslogtreecommitdiffstats
path: root/upstream/opensuse-leap-15-6/man1/pamthreshold.1
blob: 22cabcb268c06ffdc0b9e5441afdeebc3d85fa02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
\
.\" This man page was generated by the Netpbm tool 'makeman' from HTML source.
.\" Do not hand-hack it!  If you have bug fixes or improvements, please find
.\" the corresponding HTML page on the Netpbm website, generate a patch
.\" against that, and send it to the Netpbm maintainer.
.TH "Pamthreshold User Manual" 0 "06 June 2007" "netpbm documentation"

.SH NAME

pamthreshold - threshold grayscale image to black and white

.UN synopsis
.SH SYNOPSIS

\fBpamthreshold\fP
[\fB-simple\fP]
[\fB-local=\fP\fIwidth\fP\fBx\fP\fIheight\fP]
[\fB-dual=\fP\fIwidth\fP\fBx\fP\fIheight\fP]
[\fB-threshold=\fP\fIthreshold\fP]
[\fB-contrast=\fP\fIthreshold\fP]
[\fIinputpamfile\fP]
.PP
Minimum unique abbreviations of options are acceptable. You may use
double hyphens instead of a single hyphen to denote options. You may use
white space in place of the equals sign to separate an option name
from its value.

.UN description
.SH DESCRIPTION
.PP
This program is part of
.BR "Netpbm" (1)\c
\&.
.PP
\fBpamthreshold\fP thresholds a grayscale image. Thresholding means
dividing the image into background and foreground by comparing every pixel
to a thresholding value.
.PP
The input should be a PGM image or a PAM image of tuple type
GRAYSCALE or GRAYSCALE_ALPHA.  However, pamthreshold doesn't check; it
just thresholds the first channel as if it were grayscale samples and
if there is a second channel, processes it as if it is a transparency
(alpha) channel.  So if you feed it e.g. a PPM image, it will
work but produce probably useless results.
.PP
The output is a PAM with tuple type BLACKANDWHITE or
BLACKANDWHITE_ALPHA, depending on whether the input has a transparency
channel.  You can turn this into a PBM (if you need to use it with an
older program that doesn't understand PAM, or you can't afford the 8X
amount of space that PAM uses for the image) with
\fBpamtopnm\fP.
.PP
The output is to Standard Output.
.PP
When the input has a transparency channel, \fBpamthreshold\fP includes
a transparency channel in the output.  Since the output has maxval 1, the
transparency channel can indicate only fully transparent or fully opaque.
\fBpamthreshold\fP make it fully transparent where the input is more
than half transparent and fully opaque where it isn't.
.PP
The transparency function was new in Netpbm 10.43 (June 2008).  Before
that, \fBpamthreshold\fP ignores any transparency channel in the input.
.PP
Another way to convert a grayscale image to black and white is to
dither.  Dithering is using clustered black and white pixels such that
if you step back and look at the picture, you see varying levels of
gray.  \fBpamditherbw\fP does dithering.

.UN options
.SH OPTIONS
.PP
Without any options, \fBpamthreshold\fP uses a method based on the
iterative algorithm found in
the 
.UR http://www.wikipedia.org/
wikipedia
.UE
\& article
.UR http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29
 \fIThresholding (image processing)\fP
.UE
\& to compute the thresholding
value.  (
.UR http://en.wikipedia.org/w/index.php?title=Thresholding_%28image_processing%29&oldid=132306976
this version
.UE
\& of the Wikipedia article was current at the time of this
writing).  It uses this threshold to globally threshold the image.
This should work well for most images.  The program issues a message
telling you what threshold it used.  (Netpbm messages go to Standard
Error, and you can turn them off with the Netpbm common option
\fB-quiet\fP).
.PP
Options \fB-simple\fP, \fB-local\fP, and \fB-dual\fP select other
methods.



.TP
\fB-simple\fP
This selects simple or global thresholding,
i.e. \fBpamthreshold\fP compares every pixel to the threshold you
specify with \fB-threshold\fP.  Those with a brightness greater than
or equal to the threshold become white; others become black.  This
works well for black and white text pages scanned with a flatbed
scanner and is faster than the default method that iteratively
determines the thresholding value first.

.TP
\fB-local=\fP\fIwidth\fP\fBx\fP\fIheight\fP
This selects local adaptive thresholding (also known as dynamic
thresholding) using the neighborhood which is the square \fIwidth\fP pixels
wide and \fIheight\fP pixels high centered on the pixel in question.
\fBpamthreshold\fP computes the threshold individually for each pixel of the
image.  This can accommodate changing lighting conditions in the image.
Depending on the size of the neighborhood this can be quite slow.

.TP
\fB-dual=\fP\fIwidth\fP\fBx\fP\fIheight\fP
This selects a dual thresholding algorithm using a global threshold
for low contrast neighborhoods and local thresholding otherwise.  This
can preserve larger back- respectively foreground areas than local
adaptive thresholding.  This algorithm was proposed in the paper
"An Approach To Licence Plate Recognition" by J.R. Parker and Pavol Federl.

.TP
\fB-threshold=\fP\fIthreshold\fP
This sets the thresholding value for simple or local thresholding.  The
value is a floating point number in the range [0, 1] directly proportional to
the Netpbm sample values, where 0 corresponds to black and 1 to the maxval of
the image.
.sp
If you don't specify this option, \fBpamthreshold\fP uses a threshold
of 0.5.
.sp
Without \fB-simple\fP, \fB-local\fP, or \fB-dual\fP, this option is
meaningless.
.sp
The meaning of the threshold depends upon the kind of thresholding
you do (as determined by other options).  Roughly, pixels at least as
bright as the threshold become white in the output while others become
black.

.TP
\fB-contrast=\fP\fIthreshold\fP
This sets the threshold to determine if a neighborhood has low contrast
or not for dual thresholding.  The value is a floating point number in
the range [0, 1].
.sp
If you don't specify this option, \fBpamthreshold\fP uses a contrast
threshold of 0.05.  Without \fB-dual\fP this option is meaningless.




.UN seealso
.SH SEE ALSO
.BR "pamditherbw" (1)\c
\&,
.BR "ppmtopgm" (1)\c
\&,
.BR "pamtopnm" (1)\c
\&,
.BR "pam" (5)\c
\&

.UN history
.SH HISTORY
.PP
\fBpamthreshold\fP was new in Netpbm 10.34 (June 2006).

.UN author
.SH AUTHOR
.PP
\fBpamthreshold\fP is Copyright \(co 2006 by Erik Auerswald and released
under the
.BR "GPL" (1)\c
\&.
.SH DOCUMENT SOURCE
This manual page was generated by the Netpbm tool 'makeman' from HTML
source.  The master documentation is at
.IP
.B http://netpbm.sourceforge.net/doc/pamthreshold.html
.PP