# man > pamthreshold(1)

_Pamthreshold_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)            General Commands Manual           _Pamthreshold_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)

## NAME
       pamthreshold - threshold grayscale image to black and white


## SYNOPSIS
       **pamthreshold   **[**-simple**]  [**-local=_**width_**x_**height_]  [**-dual=_**width_**x_**height_]  [**-threshold=_**threshold_]
       [**-contrast=_**threshold_] [_inputpamfile_]

       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.


## DESCRIPTION
       This program is part of [**Netpbm**(1)](https://www.chedong.com/phpMan.php/man/Netpbm/1/markdown).

       **pamthreshold  **thresholds  a grayscale image. Thresholding means dividing the image into back‐
       ground and foreground by comparing every pixel to a thresholding value.

       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 use‐
       less results.

       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 **pamtopnm**.

       The output is to Standard Output.

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

       The transparency function was new in Netpbm 10.43 (June 2008).  Before that, **pamthreshold **ig‐
       nores any transparency channel in the input.

       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.  **pamditherbw **does dithering.


## OPTIONS
       In  addition  to  the options common to all programs based on libnetpbm (most notably **-quiet**,
       see ]8;;index.html#commonoptions\ Common Options]8;;\ ), **pamthreshold **recognizes the following command line options:

       Without any options, **pamthreshold **uses a method based on the iterative algorithm found in the
       ]8;;<http://www.wikipedia.org/>\wikipedia]8;;\  article ]8;;<http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29>\ _Thresholding_ _(image_ _processing)_]8;;\  to compute the  thresholding  value.   (
       ]8;;<http://en.wikipedia.org/w/index.php?title=Thresholding_%28image_processing%29&oldid=132306976>\this version]8;;\    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 **-quiet**).

       Options **-simple**, **-local**, and **-dual **select other methods.




### -simple
              This  selects simple or global thresholding, i.e. **pamthreshold **compares every pixel to
              the threshold you specify with **-threshold**.  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.


### -local=_
              This  selects  local  adaptive thresholding (also known as dynamic thresholding) using
              the neighborhood which is the square _width_ pixels wide and _height_ pixels high centered
              on the pixel in question.  **pamthreshold **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.


### -dual=_
              This selects a dual thresholding algorithm using a global threshold for  low  contrast
              neighborhoods  and  local  thresholding otherwise.  This can preserve larger back- re‐
              spectively foreground areas than local adaptive thresholding.  This algorithm was pro‐
              posed in the paper "An Approach To Licence Plate Recognition" by J.R. Parker and Pavol
              Federl.


### -threshold=_
              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.

              If you don't specify this option, **pamthreshold **uses a threshold of 0.5.

              Without **-simple**, **-local**, or **-dual**, this option is meaningless.

              The meaning of the threshold depends upon the kind of thresholding you do  (as  deter‐
              mined  by  other options).  Roughly, pixels at least as bright as the threshold become
              white in the output while others become black.


### -contrast=_
              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].

              If  you  don't  specify  this  option, **pamthreshold **uses a contrast threshold of 0.05.
              Without **-dual **this option is meaningless.





## SEE ALSO
       [**pamditherbw**(1)](https://www.chedong.com/phpMan.php/man/pamditherbw/1/markdown), [**ppmtopgm**(1)](https://www.chedong.com/phpMan.php/man/ppmtopgm/1/markdown), [**pamtopnm**(1)](https://www.chedong.com/phpMan.php/man/pamtopnm/1/markdown), [**pam**(1)](https://www.chedong.com/phpMan.php/man/pam/1/markdown)


## HISTORY
       **pamthreshold **was new in Netpbm 10.34 (June 2006).


## AUTHOR
       **pamthreshold **is Copyright © 2006 by Erik Auerswald and released under the [**GPL**(1)](https://www.chedong.com/phpMan.php/man/GPL/1/markdown).

## DOCUMENT SOURCE
       This manual page was generated by the Netpbm tool 'makeman' from  HTML  source.   The  master
       documentation is at

              **<http://netpbm.sourceforge.net/doc/pamthreshold.html>**

netpbm documentation                        06 June 2007                 _Pamthreshold_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)
