Blame userguide/pamthreshold.html

Packit 78deda
Packit 78deda
<HTML>
Packit 78deda
<HEAD><TITLE>Pamthreshold User Manual</TITLE></HEAD>
Packit 78deda
<BODY>
Packit 78deda

pamthreshold

Packit 78deda
Updated: 06 June 2007
Packit 78deda

Packit 78deda
Table Of Contents
Packit 78deda
Packit 78deda

NAME

Packit 78deda
Packit 78deda
pamthreshold - threshold grayscale image to black and white
Packit 78deda
Packit 78deda

SYNOPSIS

Packit 78deda
Packit 78deda
pamthreshold
Packit 78deda
[-simple]
Packit 78deda
[-local=widthxheight]
Packit 78deda
[-dual=widthxheight]
Packit 78deda
[-threshold=threshold]
Packit 78deda
[-contrast=threshold]
Packit 78deda
[inputpamfile]
Packit 78deda
Packit 78deda

Minimum unique abbreviations of options are acceptable. You may use

Packit 78deda
double hyphens instead of a single hyphen to denote options. You may use
Packit 78deda
white space in place of the equals sign to separate an option name
Packit 78deda
from its value.
Packit 78deda
Packit 78deda

DESCRIPTION

Packit 78deda
Packit 78deda

This program is part of Netpbm.

Packit 78deda
Packit 78deda

pamthreshold thresholds a grayscale image. Thresholding means

Packit 78deda
dividing the image into background and foreground by comparing every pixel
Packit 78deda
to a thresholding value.
Packit 78deda
Packit 78deda

The input should be a PGM image or a PAM image of tuple type

Packit 78deda
GRAYSCALE or GRAYSCALE_ALPHA.  However, pamthreshold doesn't check; it
Packit 78deda
just thresholds the first channel as if it were grayscale samples and
Packit 78deda
if there is a second channel, processes it as if it is a transparency
Packit 78deda
(alpha) channel.  So if you feed it e.g. a PPM image, it will
Packit 78deda
work but produce probably useless results.
Packit 78deda
Packit 78deda

The output is a PAM with tuple type BLACKANDWHITE or

Packit 78deda
BLACKANDWHITE_ALPHA, depending on whether the input has a transparency
Packit 78deda
channel.  You can turn this into a PBM (if you need to use it with an
Packit 78deda
older program that doesn't understand PAM, or you can't afford the 8X
Packit 78deda
amount of space that PAM uses for the image) with
Packit 78deda
pamtopnm.
Packit 78deda
Packit 78deda

The output is to Standard Output.

Packit 78deda
Packit 78deda

When the input has a transparency channel, pamthreshold includes

Packit 78deda
a transparency channel in the output.  Since the output has maxval 1, the
Packit 78deda
transparency channel can indicate only fully transparent or fully opaque.
Packit 78deda
pamthreshold make it fully transparent where the input is more
Packit 78deda
than half transparent and fully opaque where it isn't.
Packit 78deda
Packit 78deda

The transparency function was new in Netpbm 10.43 (June 2008). Before

Packit 78deda
that, pamthreshold ignores any transparency channel in the input.
Packit 78deda
Packit 78deda

Another way to convert a grayscale image to black and white is to

Packit 78deda
dither.  Dithering is using clustered black and white pixels such that
Packit 78deda
if you step back and look at the picture, you see varying levels of
Packit 78deda
gray.  pamditherbw does dithering.
Packit 78deda
Packit 78deda

OPTIONS

Packit 78deda
Packit 78deda

Without any options, pamthreshold uses a method based on the

Packit 78deda
iterative algorithm found in
Packit 78deda
the wikipedia article
Packit 78deda
Packit 78deda
Thresholding (image processing) to compute the thresholding
Packit 78deda
value.  (
Packit 78deda
href="http://en.wikipedia.org/w/index.php?title=Thresholding_%28image_processing%29&oldid=132306976">this
Packit 78deda
version of the Wikipedia article was current at the time of this
Packit 78deda
writing).  It uses this threshold to globally threshold the image.
Packit 78deda
This should work well for most images.  The program issues a message
Packit 78deda
telling you what threshold it used.  (Netpbm messages go to Standard
Packit 78deda
Error, and you can turn them off with the Netpbm common option
Packit 78deda
-quiet).
Packit 78deda
Packit 78deda

Options -simple, -local, and -dual select other

Packit 78deda
methods.
Packit 78deda
Packit 78deda
Packit 78deda
Packit 78deda
-simple
Packit 78deda
Packit 78deda
This selects simple or global thresholding,
Packit 78deda
i.e. pamthreshold compares every pixel to the threshold you
Packit 78deda
specify with -threshold.  Those with a brightness greater than
Packit 78deda
or equal to the threshold become white; others become black.  This
Packit 78deda
works well for black and white text pages scanned with a flatbed
Packit 78deda
scanner and is faster than the default method that iteratively
Packit 78deda
determines the thresholding value first.
Packit 78deda
Packit 78deda
-local=widthxheight
Packit 78deda
Packit 78deda
This selects local adaptive thresholding (also known as dynamic
Packit 78deda
thresholding) using the neighborhood which is the square width pixels
Packit 78deda
wide and height pixels high centered on the pixel in question.
Packit 78deda
pamthreshold computes the threshold individually for each pixel of the
Packit 78deda
image.  This can accommodate changing lighting conditions in the image.
Packit 78deda
Depending on the size of the neighborhood this can be quite slow.
Packit 78deda
Packit 78deda
-dual=widthxheight
Packit 78deda
Packit 78deda
This selects a dual thresholding algorithm using a global threshold
Packit 78deda
for low contrast neighborhoods and local thresholding otherwise.  This
Packit 78deda
can preserve larger back- respectively foreground areas than local
Packit 78deda
adaptive thresholding.  This algorithm was proposed in the paper
Packit 78deda
"An Approach To Licence Plate Recognition" by J.R. Parker and Pavol Federl.
Packit 78deda
Packit 78deda
-threshold=threshold
Packit 78deda
Packit 78deda
This sets the thresholding value for simple or local thresholding. The
Packit 78deda
value is a floating point number in the range [0, 1] directly proportional to
Packit 78deda
the Netpbm sample values, where 0 corresponds to black and 1 to the maxval of
Packit 78deda
the image.
Packit 78deda
Packit 78deda

If you don't specify this option, pamthreshold uses a threshold

Packit 78deda
of 0.5.
Packit 78deda
Packit 78deda

Without -simple, -local, or -dual, this option is

Packit 78deda
meaningless.
Packit 78deda
Packit 78deda

The meaning of the threshold depends upon the kind of thresholding

Packit 78deda
you do (as determined by other options).  Roughly, pixels at least as
Packit 78deda
bright as the threshold become white in the output while others become
Packit 78deda
black.
Packit 78deda
Packit 78deda
-contrast=threshold
Packit 78deda
Packit 78deda
This sets the threshold to determine if a neighborhood has low contrast
Packit 78deda
or not for dual thresholding.  The value is a floating point number in
Packit 78deda
the range [0, 1].
Packit 78deda
Packit 78deda

If you don't specify this option, pamthreshold uses a contrast

Packit 78deda
threshold of 0.05.  Without -dual this option is meaningless.
Packit 78deda
Packit 78deda
Packit 78deda
Packit 78deda
Packit 78deda

SEE ALSO

Packit 78deda
Packit 78deda
pamditherbw,
Packit 78deda
ppmtopgm,
Packit 78deda
pamtopnm,
Packit 78deda
pam
Packit 78deda
Packit 78deda

HISTORY

Packit 78deda
Packit 78deda

pamthreshold was new in Netpbm 10.34 (June 2006).

Packit 78deda
Packit 78deda

AUTHOR

Packit 78deda

Packit 78deda
pamthreshold is Copyright © 2006 by Erik Auerswald and released
Packit 78deda
under the GPL.
Packit 78deda
Packit 78deda

Packit 78deda

Table Of Contents

Packit 78deda
    Packit 78deda
  • SYNOPSIS
  • Packit 78deda
  • OPTIONS
  • Packit 78deda
  • DESCRIPTION
  • Packit 78deda
  • SEE ALSO
  • Packit 78deda
  • HISTORY
  • Packit 78deda
  • AUTHOR
  • Packit 78deda
    Packit 78deda
    </BODY>
    Packit 78deda
    </HTML>
    Packit 78deda