{
    "mode": "man",
    "parameter": "pamthreshold",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pamthreshold/1/json",
    "generated": "2026-08-06T16:06:26Z",
    "synopsis": "pamthreshold   [-simple]  [-local=widthxheight]  [-dual=widthxheight]  [-threshold=threshold]\n[-contrast=threshold] [inputpamfile]\nMinimum unique abbreviations of options are acceptable. You may use double hyphens instead of\na single hyphen to denote options. You may use white space in place of  the  equals  sign  to\nseparate an option name from its value.",
    "sections": {
        "NAME": {
            "content": "pamthreshold - threshold grayscale image to black and white\n\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pamthreshold   [-simple]  [-local=widthxheight]  [-dual=widthxheight]  [-threshold=threshold]\n[-contrast=threshold] [inputpamfile]\n\nMinimum unique abbreviations of options are acceptable. You may use double hyphens instead of\na single hyphen to denote options. You may use white space in place of  the  equals  sign  to\nseparate an option name from its value.\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This program is part of Netpbm(1).\n\npamthreshold  thresholds  a grayscale image. Thresholding means dividing the image into back‐\nground and foreground by comparing every pixel to a thresholding value.\n\nThe input should be a PGM image or a PAM image of tuple type  GRAYSCALE  or  GRAYSCALEALPHA.\nHowever,  pamthreshold  doesn't  check;  it  just  thresholds the first channel as if it were\ngrayscale samples and if there is a second channel, processes it as if it is  a  transparency\n(alpha)  channel.  So if you feed it e.g. a PPM image, it will work but produce probably use‐\nless results.\n\nThe output is a PAM with  tuple  type  BLACKANDWHITE  or  BLACKANDWHITEALPHA,  depending  on\nwhether  the  input has a transparency channel.  You can turn this into a PBM (if you need to\nuse it with an older program that doesn't understand PAM, or you can't afford the  8X  amount\nof space that PAM uses for the image) with pamtopnm.\n\nThe output is to Standard Output.\n\nWhen  the  input  has a transparency channel, pamthreshold includes a transparency channel in\nthe output.  Since the output has maxval 1, the transparency channel can indicate only  fully\ntransparent  or fully opaque.  pamthreshold make it fully transparent where the input is more\nthan half transparent and fully opaque where it isn't.\n\nThe transparency function was new in Netpbm 10.43 (June 2008).  Before that, pamthreshold ig‐\nnores any transparency channel in the input.\n\nAnother way to convert a grayscale image to black and white is to dither.  Dithering is using\nclustered black and white pixels such that if you step back and look at the picture, you  see\nvarying levels of gray.  pamditherbw does dithering.\n\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "In  addition  to  the options common to all programs based on libnetpbm (most notably -quiet,\nsee \u001b]8;;index.html#commonoptions\u001b\\ Common Options\u001b]8;;\u001b\\ ), pamthreshold recognizes the following command line options:\n\nWithout any options, pamthreshold uses a method based on the iterative algorithm found in the\n\u001b]8;;http://www.wikipedia.org/\u001b\\wikipedia\u001b]8;;\u001b\\  article \u001b]8;;http://en.wikipedia.org/wiki/Thresholding%28imageprocessing%29\u001b\\ Thresholding (image processing)\u001b]8;;\u001b\\  to compute the  thresholding  value.   (\n\u001b]8;;http://en.wikipedia.org/w/index.php?title=Thresholding%28imageprocessing%29&oldid=132306976\u001b\\this version\u001b]8;;\u001b\\    of  the  Wikipedia article was current at the time of this writing).  It uses\nthis threshold to globally threshold the image.  This should work well for most images.   The\nprogram issues a message telling you what threshold it used.  (Netpbm messages go to Standard\nError, and you can turn them off with the Netpbm common option -quiet).\n\nOptions -simple, -local, and -dual select other methods.\n\n\n\n",
            "subsections": [
                {
                    "name": "-simple",
                    "content": "This  selects simple or global thresholding, i.e. pamthreshold compares every pixel to\nthe threshold you specify with -threshold.  Those with a brightness  greater  than  or\nequal  to  the threshold become white; others become black.  This works well for black\nand white text pages scanned with a flatbed scanner and is  faster  than  the  default\nmethod that iteratively determines the thresholding value first.\n\n"
                },
                {
                    "name": "-local=_",
                    "content": "This  selects  local  adaptive thresholding (also known as dynamic thresholding) using\nthe neighborhood which is the square width pixels wide and height pixels high centered\non the pixel in question.  pamthreshold computes the threshold individually  for  each\npixel  of  the image.  This can accommodate changing lighting conditions in the image.\nDepending on the size of the neighborhood this can be quite slow.\n\n"
                },
                {
                    "name": "-dual=_",
                    "content": "This selects a dual thresholding algorithm using a global threshold for  low  contrast\nneighborhoods  and  local  thresholding otherwise.  This can preserve larger back- re‐\nspectively foreground areas than local adaptive thresholding.  This algorithm was pro‐\nposed in the paper \"An Approach To Licence Plate Recognition\" by J.R. Parker and Pavol\nFederl.\n\n"
                },
                {
                    "name": "-threshold=_",
                    "content": "This sets the thresholding value for simple or local thresholding.   The  value  is  a\nfloating  point  number in the range [0, 1] directly proportional to the Netpbm sample\nvalues, where 0 corresponds to black and 1 to the maxval of the image.\n\nIf you don't specify this option, pamthreshold uses a threshold of 0.5.\n\nWithout -simple, -local, or -dual, this option is meaningless.\n\nThe meaning of the threshold depends upon the kind of thresholding you do  (as  deter‐\nmined  by  other options).  Roughly, pixels at least as bright as the threshold become\nwhite in the output while others become black.\n\n"
                },
                {
                    "name": "-contrast=_",
                    "content": "This sets the threshold to determine if a neighborhood has low  contrast  or  not  for\ndual thresholding.  The value is a floating point number in the range [0, 1].\n\nIf  you  don't  specify  this  option, pamthreshold uses a contrast threshold of 0.05.\nWithout -dual this option is meaningless.\n\n\n\n\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "pamditherbw(1), ppmtopgm(1), pamtopnm(1), pam(1)\n\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "pamthreshold was new in Netpbm 10.34 (June 2006).\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "pamthreshold is Copyright © 2006 by Erik Auerswald and released under the GPL(1).\n",
            "subsections": []
        },
        "DOCUMENT SOURCE": {
            "content": "This manual page was generated by the Netpbm tool 'makeman' from  HTML  source.   The  master\ndocumentation is at\n\nhttp://netpbm.sourceforge.net/doc/pamthreshold.html\n\nnetpbm documentation                        06 June 2007                 Pamthreshold User Manual(1)",
            "subsections": []
        }
    },
    "summary": "pamthreshold - threshold grayscale image to black and white",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "pamditherbw",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pamditherbw/1/json"
        },
        {
            "name": "ppmtopgm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ppmtopgm/1/json"
        },
        {
            "name": "pamtopnm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pamtopnm/1/json"
        },
        {
            "name": "pam",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pam/1/json"
        }
    ]
}