{
    "mode": "man",
    "parameter": "pnmhisteq",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pnmhisteq/1/json",
    "generated": "2026-06-17T13:36:41Z",
    "synopsis": "pnmhisteq [-gray] [-rmap pgmfile] [-wmap pgmfile] [-verbose] [pnmfile]",
    "sections": {
        "NAME": {
            "content": "pnmhisteq - histogram equalise a portable anymap\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pnmhisteq [-gray] [-rmap pgmfile] [-wmap pgmfile] [-verbose] [pnmfile]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "pnmhisteq  increases  the  contrast  of a portable graymap or pixmap through the technique of\nhistogram equalisation[1].  A histogram of the luminance of pixels in the  map  is  computed,\nfrom  which  a transfer function is calculated which spreads out intensity levels around his‐\ntogram peaks and compresses them at troughs.  This has the effect of using the available lev‐\nels of intensity more efficiently and thereby increases the detail visible in the image.\n\nMathematically, if N[i] is the number of pixels of luminosity i in the image and T is the to‐\ntal number of pixels, luminosity j is replaced by:\n\nj\n---\n\\\n>   N[i] / T\n\n---\ni=0\n\nIf you're processing a related set of images, for example frames of an animation, it's gener‐\nally  best  to  apply  the same intensity map to every frame, since otherwise you'll get dis‐\ntracting frame-to-frame changes in the brightness of objects.  pnmhisteq's -wmap  option  al‐\nlows you to save, as a portable graymap, the luminosity map computed from an image (usually a\ncomposite of the images you intend to process created with pnmcat).   Then,  you  can  subse‐\nquently  process  each  of  the individual images using the luminosity map saved in the file,\nsupplied with the -rmap option.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-gray",
                    "content": "blue  values) are included in the histogram and modified in the output image.  This\nis a special purpose option intended for images where  the  actual  data  are  gray\nscale,  with  colour annotations you don't want modified.  Weather satellite images\nthat show continent outlines in colour are best processed using this  option.   The\noption has no effect when the input is a graymap.\n"
                },
                {
                    "name": "-rmap",
                    "content": "Process  the  image using the luminosity map specified by the portable graymap map‐\nfile.  The graymap, usually created by an earlier run of pnmhisteq with  the  -wmap\noption,  contains a single row with number of columns equal to the maxval (greatest\nintensity) of the image.  Each pixel in the image is transformed by looking up  its\nluminosity in the corresponding column in the map file and changing it to the value\ngiven by that column.\n"
                },
                {
                    "name": "-wmap",
                    "content": "Creates a portable graymap, mapfile, containing the luminosity  map  computed  from\nthe  histogram of the input image.  This map file can be read on subsequent runs of\npnmhisteq with the -rmap option, allowing a group of images to be processed with an\nidentical map.\n"
                },
                {
                    "name": "-verbose",
                    "content": "All flags can be abbreviated to their shortest unique prefix.\n"
                }
            ]
        },
        "BUGS": {
            "content": "Histogram  equalisation  is effective for increasing the visible detail in scientific imagery\nand in some continuous-tone pictures.  It is often too drastic, however, for scanned halftone\nimages, where it does an excellent job of making halftone artifacts apparent.  You might want\nto experiment with pgnnorm, ppmnorm, and pnmgamma for more subtle contrast enhancement.\n\nThe luminosity map file supplied by the -rmap option must have the same maxval as  the  input\nimage.   This is always the case when the map file was created by the -wmap option of pnmhis‐‐\nteq.  If this restriction causes a problem, simply adjust the maxval of the map with pnmdepth\nto agree with the input image.\n\nIf  the  input  is a PBM file (on which histogram equalisation is an identity operation), the\nonly effect of passing the file through pnmhisteq will be the passage of time.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pgmnorm(1), pnm(5), pnmcat(1), pnmdepth(1), pnmgamma(1), pnmnorm(1)\n\n[1]  Russ, John C.  The Image Processing Handbook.   Boca  Raton:  CRC  Press,  1992.   Pages\n105-110.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Copyright (C) 1995 by John Walker (kelvin@fourmilab.ch).\nWWW home page: http://www.fourmilab.ch/\n\nPermission  to  use, copy, modify, and distribute this software and its documentation for any\npurpose and without fee is hereby granted, without  any  conditions  or  restrictions.   This\nsoftware is provided ``as is'' without express or implied warranty.\n\n\n\n19 March 1995                               pnmhisteq(1)",
            "subsections": []
        }
    },
    "summary": "pnmhisteq - histogram equalise a portable anymap",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "blue values) are included in the histogram and modified in the output image. This is a special purpose option intended for images where the actual data are gray scale, with colour annotations you don't want modified. Weather satellite images that show continent outlines in colour are best processed using this option. The option has no effect when the input is a graymap."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Process the image using the luminosity map specified by the portable graymap map‐ file. The graymap, usually created by an earlier run of pnmhisteq with the -wmap option, contains a single row with number of columns equal to the maxval (greatest intensity) of the image. Each pixel in the image is transformed by looking up its luminosity in the corresponding column in the map file and changing it to the value given by that column."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Creates a portable graymap, mapfile, containing the luminosity map computed from the histogram of the input image. This map file can be read on subsequent runs of pnmhisteq with the -rmap option, allowing a group of images to be processed with an identical map."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "All flags can be abbreviated to their shortest unique prefix."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "pgmnorm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pgmnorm/1/json"
        },
        {
            "name": "pnm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/5/json"
        },
        {
            "name": "pnmcat",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmcat/1/json"
        },
        {
            "name": "pnmdepth",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmdepth/1/json"
        },
        {
            "name": "pnmgamma",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmgamma/1/json"
        },
        {
            "name": "pnmnorm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmnorm/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Histogram-equalize a PNM image.",
        "examples": [
            {
                "description": "Increase the contrast of a PNM image using histogram equalization",
                "command": "pnmhisteq {{path/to/input.pnm}} > {{path/to/output.pnm}}"
            },
            {
                "description": "Only modify grey pixels",
                "command": "pnmhisteq {{-g|-grey}} {{path/to/input.pnm}} > {{path/to/output.pnm}}"
            },
            {
                "description": "Do not include black or white pixels in the histogram equalization",
                "command": "pnmhisteq -no{{black|white}} {{path/to/input.pnm}} > {{path/to/output.pnm}}"
            }
        ]
    }
}