| 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 "Pamthreshold User Manual" 1 "06 June 2007" "netpbm documentation" |
| 7 |
|
| 8 |
.SH NAME |
| 9 |
|
| 10 |
pamthreshold - threshold grayscale image to black and white |
| 11 |
|
| 12 |
.UN synopsis |
| 13 |
.SH SYNOPSIS |
| 14 |
|
| 15 |
\fBpamthreshold\fP |
| 16 |
[\fB-simple\fP] |
| 17 |
[\fB-local=\fP\fIwidth\fP\fBx\fP\fIheight\fP] |
| 18 |
[\fB-dual=\fP\fIwidth\fP\fBx\fP\fIheight\fP] |
| 19 |
[\fB-threshold=\fP\fIthreshold\fP] |
| 20 |
[\fB-contrast=\fP\fIthreshold\fP] |
| 21 |
[\fIinputpamfile\fP] |
| 22 |
.PP |
| 23 |
Minimum unique abbreviations of options are acceptable. You may use |
| 24 |
double hyphens instead of a single hyphen to denote options. You may use |
| 25 |
white space in place of the equals sign to separate an option name |
| 26 |
from its value. |
| 27 |
|
| 28 |
.UN description |
| 29 |
.SH DESCRIPTION |
| 30 |
.PP |
| 31 |
This program is part of |
| 32 |
.BR "Netpbm" (1)\c |
| 33 |
\&. |
| 34 |
.PP |
| 35 |
\fBpamthreshold\fP thresholds a grayscale image. Thresholding means |
| 36 |
dividing the image into background and foreground by comparing every pixel |
| 37 |
to a thresholding value. |
| 38 |
.PP |
| 39 |
The input should be a PGM image or a PAM image of tuple type |
| 40 |
GRAYSCALE or GRAYSCALE_ALPHA. However, pamthreshold doesn't check; it |
| 41 |
just thresholds the first channel as if it were grayscale samples and |
| 42 |
if there is a second channel, processes it as if it is a transparency |
| 43 |
(alpha) channel. So if you feed it e.g. a PPM image, it will |
| 44 |
work but produce probably useless results. |
| 45 |
.PP |
| 46 |
The output is a PAM with tuple type BLACKANDWHITE or |
| 47 |
BLACKANDWHITE_ALPHA, depending on whether the input has a transparency |
| 48 |
channel. You can turn this into a PBM (if you need to use it with an |
| 49 |
older program that doesn't understand PAM, or you can't afford the 8X |
| 50 |
amount of space that PAM uses for the image) with |
| 51 |
\fBpamtopnm\fP. |
| 52 |
.PP |
| 53 |
The output is to Standard Output. |
| 54 |
.PP |
| 55 |
When the input has a transparency channel, \fBpamthreshold\fP includes |
| 56 |
a transparency channel in the output. Since the output has maxval 1, the |
| 57 |
transparency channel can indicate only fully transparent or fully opaque. |
| 58 |
\fBpamthreshold\fP make it fully transparent where the input is more |
| 59 |
than half transparent and fully opaque where it isn't. |
| 60 |
.PP |
| 61 |
The transparency function was new in Netpbm 10.43 (June 2008). Before |
| 62 |
that, \fBpamthreshold\fP ignores any transparency channel in the input. |
| 63 |
.PP |
| 64 |
Another way to convert a grayscale image to black and white is to |
| 65 |
dither. Dithering is using clustered black and white pixels such that |
| 66 |
if you step back and look at the picture, you see varying levels of |
| 67 |
gray. \fBpamditherbw\fP does dithering. |
| 68 |
|
| 69 |
.UN options |
| 70 |
.SH OPTIONS |
| 71 |
.PP |
| 72 |
In addition to the options common to all programs based on libnetpbm |
| 73 |
(most notably \fB-quiet\fP, see |
| 74 |
.UR index.html#commonoptions |
| 75 |
Common Options |
| 76 |
.UE |
| 77 |
\&), \fBpamthreshold\fP recognizes the following |
| 78 |
command line options: |
| 79 |
.PP |
| 80 |
Without any options, \fBpamthreshold\fP uses a method based on the |
| 81 |
iterative algorithm found in |
| 82 |
the |
| 83 |
.UR http://www.wikipedia.org/ |
| 84 |
wikipedia |
| 85 |
.UE |
| 86 |
\& article |
| 87 |
.UR http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29 |
| 88 |
\fIThresholding (image processing)\fP |
| 89 |
.UE |
| 90 |
\& to compute the thresholding |
| 91 |
value. ( |
| 92 |
.UR http://en.wikipedia.org/w/index.php?title=Thresholding_%28image_processing%29&oldid=132306976 |
| 93 |
this version |
| 94 |
.UE |
| 95 |
\& of the Wikipedia article was current at the time of this |
| 96 |
writing). It uses this threshold to globally threshold the image. |
| 97 |
This should work well for most images. The program issues a message |
| 98 |
telling you what threshold it used. (Netpbm messages go to Standard |
| 99 |
Error, and you can turn them off with the Netpbm common option |
| 100 |
\fB-quiet\fP). |
| 101 |
.PP |
| 102 |
Options \fB-simple\fP, \fB-local\fP, and \fB-dual\fP select other |
| 103 |
methods. |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
.TP |
| 108 |
\fB-simple\fP |
| 109 |
This selects simple or global thresholding, |
| 110 |
i.e. \fBpamthreshold\fP compares every pixel to the threshold you |
| 111 |
specify with \fB-threshold\fP. Those with a brightness greater than |
| 112 |
or equal to the threshold become white; others become black. This |
| 113 |
works well for black and white text pages scanned with a flatbed |
| 114 |
scanner and is faster than the default method that iteratively |
| 115 |
determines the thresholding value first. |
| 116 |
|
| 117 |
.TP |
| 118 |
\fB-local=\fP\fIwidth\fP\fBx\fP\fIheight\fP |
| 119 |
This selects local adaptive thresholding (also known as dynamic |
| 120 |
thresholding) using the neighborhood which is the square \fIwidth\fP pixels |
| 121 |
wide and \fIheight\fP pixels high centered on the pixel in question. |
| 122 |
\fBpamthreshold\fP computes the threshold individually for each pixel of the |
| 123 |
image. This can accommodate changing lighting conditions in the image. |
| 124 |
Depending on the size of the neighborhood this can be quite slow. |
| 125 |
|
| 126 |
.TP |
| 127 |
\fB-dual=\fP\fIwidth\fP\fBx\fP\fIheight\fP |
| 128 |
This selects a dual thresholding algorithm using a global threshold |
| 129 |
for low contrast neighborhoods and local thresholding otherwise. This |
| 130 |
can preserve larger back- respectively foreground areas than local |
| 131 |
adaptive thresholding. This algorithm was proposed in the paper |
| 132 |
"An Approach To Licence Plate Recognition" by J.R. Parker and Pavol Federl. |
| 133 |
|
| 134 |
.TP |
| 135 |
\fB-threshold=\fP\fIthreshold\fP |
| 136 |
This sets the thresholding value for simple or local thresholding. The |
| 137 |
value is a floating point number in the range [0, 1] directly proportional to |
| 138 |
the Netpbm sample values, where 0 corresponds to black and 1 to the maxval of |
| 139 |
the image. |
| 140 |
.sp |
| 141 |
If you don't specify this option, \fBpamthreshold\fP uses a threshold |
| 142 |
of 0.5. |
| 143 |
.sp |
| 144 |
Without \fB-simple\fP, \fB-local\fP, or \fB-dual\fP, this option is |
| 145 |
meaningless. |
| 146 |
.sp |
| 147 |
The meaning of the threshold depends upon the kind of thresholding |
| 148 |
you do (as determined by other options). Roughly, pixels at least as |
| 149 |
bright as the threshold become white in the output while others become |
| 150 |
black. |
| 151 |
|
| 152 |
.TP |
| 153 |
\fB-contrast=\fP\fIthreshold\fP |
| 154 |
This sets the threshold to determine if a neighborhood has low contrast |
| 155 |
or not for dual thresholding. The value is a floating point number in |
| 156 |
the range [0, 1]. |
| 157 |
.sp |
| 158 |
If you don't specify this option, \fBpamthreshold\fP uses a contrast |
| 159 |
threshold of 0.05. Without \fB-dual\fP this option is meaningless. |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
.UN seealso |
| 165 |
.SH SEE ALSO |
| 166 |
.BR "pamditherbw" (1)\c |
| 167 |
\&, |
| 168 |
.BR "ppmtopgm" (1)\c |
| 169 |
\&, |
| 170 |
.BR "pamtopnm" (1)\c |
| 171 |
\&, |
| 172 |
.BR "pam" (1)\c |
| 173 |
\& |
| 174 |
|
| 175 |
.UN history |
| 176 |
.SH HISTORY |
| 177 |
.PP |
| 178 |
\fBpamthreshold\fP was new in Netpbm 10.34 (June 2006). |
| 179 |
|
| 180 |
.UN author |
| 181 |
.SH AUTHOR |
| 182 |
.PP |
| 183 |
\fBpamthreshold\fP is Copyright \(co 2006 by Erik Auerswald and released |
| 184 |
under the |
| 185 |
.BR "GPL" (1)\c |
| 186 |
\&. |
| 187 |
.SH DOCUMENT SOURCE |
| 188 |
This manual page was generated by the Netpbm tool 'makeman' from HTML |
| 189 |
source. The master documentation is at |
| 190 |
.IP |
| 191 |
.B http://netpbm.sourceforge.net/doc/pamthreshold.html |
| 192 |
.PP |