Plan 9 from Bell Labs’s /usr/web/sources/contrib/pac/sys/doc/netpbm/ms/pamthreshold.ms

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.TL
Pamthreshold User Manual
.SH 1
pamthreshold
.LP
Updated: 12 May 2006
.br
Table Of Contents
.SH 2
NAME
.LP
pamthreshold - threshold grayscale image to black and white
.SH 2
SYNOPSIS
.LP
\fBpamthreshold\fR
[\fB-simple\fR]
[\fB-local=\fR\fIwidth\fR\fBx\fR\fIheight\fR]
[\fB-dual=\fR\fIwidth\fR\fBx\fR\fIheight\fR]
[\fB-threshold=\fR\fIthreshold\fR]
[\fB-contrast=\fR\fIthreshold\fR]
[\fIinputpamfile\fR]
.LP
Minimum unique abbreviation of options is 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.
.SH 2
DESCRIPTION
.LP
.LP
This program is part of Netpbm.
.LP
\fBpamthreshold\fR thresholds a grayscale image. Thresholding means
dividing the image into background and foreground by comparing every pixel
to a thresholding value.
.LP
The input should be a PGM image or a PAM image of tuple type
GRAYSCALE.  However, pamthreshold doesn't check; it just thresholds the
first channel as if it were grayscale samples.  So if you
feed it e.g. a PPM image, it will work but produce probably useless
results.
.LP
The output is a PAM with tuple type BLACKANDWHITE. You can turn this
into a PBM (if you need to use it with an older program that doesn't
understand PAM) with \fBpamtopnm\fR.
.LP
The output is to Standard Output.
.LP
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\fR does dithering.
.SH 2
OPTIONS
.LP
.LP
Without any options, \fBpamthreshold\fR uses an iterative
algorithm found in the wikipedia article
\fIThresholding (image processing)\fR to compute the
thresholding value.  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 command
option \fB-quiet\fR).
.RS
.IP "\fB-simple\fR"
This selects simple or global thresholding,
i.e. \fBpamthreshold\fR compares every pixel to the threshold you
specify with \fB-threshold\fR.  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.
.IP "\fB-local=\fR\fIwidth\fR\fBx\fR\fIheight\fR"
This selects local adaptive thresholding (also known as dynamic
thresholding) using the neighborhood of \fIwidth\fR and \fIheight\fR
around every pixel.  \fBpamthreshold\fR 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.
.IP "\fB-dual=\fR\fIwidth\fR\fBx\fR\fIheight\fR"
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.
.IP "\fB-threshold=\fR\fIthreshold\fR"
This sets the thresholding value for simple or local thresholding.
The value is a floating point number in the range [0, 1], where 0
is black and 1 is the maxval of the image.
.LP
If you don't specify this option, \fBpamthreshold\fR uses a threshold
of 0.5.  Without \fB-simple\fR or \fB-local\fR this option is
meaningless.
.IP "\fB-contrast=\fR\fIthreshold\fR"
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].
.LP
If you don't specify this option, \fBpamthreshold\fR uses a contrast
threshold of 0.05.  Without \fB-dual\fR this option is meaningless.
.RE
.SH 2
SEE ALSO
.LP
\fBpamditherbw\fR,
\fBppmtopgm\fR,
\fBpamtopnm\fR,
\fBpam\fR
.SH 2
HISTORY
.LP
.LP
\fBpamthreshold\fR was new in Netpbm 10.34 (June 2006).
.SH 2
AUTHOR
.LP
.LP
\fBpamthreshold\fR is Copyright © 2006 by Erik Auerswald and released
under the GPL.
.br
\l'5i'
.SH 2
Table Of Contents
.LP
.IP \(bu
NAME
.IP \(bu
SYNOPSIS
.IP \(bu
OPTIONS
.IP \(bu
DESCRIPTION
.IP \(bu
SEE ALSO
.IP \(bu
HISTORY
.IP \(bu
AUTHOR
.LP

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.