{
    "mode": "man",
    "parameter": "ppmhist",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/ppmhist/1/json",
    "generated": "2026-10-04T06:37:16Z",
    "synopsis": "ppmhist [-hexcolor | -float | -colorname | -map] [-nomap] [-noheader] [-sort={frequency,rgb}]\n[-forensic] [ppmfile]",
    "sections": {
        "NAME": {
            "content": "ppmhist - print a histogram of the colors in a PPM image\n\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "ppmhist [-hexcolor | -float | -colorname | -map] [-nomap] [-noheader] [-sort={frequency,rgb}]\n[-forensic] [ppmfile]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This program is part of Netpbm(1).\n\nppmhist reads a PPM image as input and generates a histogram of the colors in the image, i.e.\na list of all the colors and how many pixels of each color are in the image.\n\n",
            "subsections": [
                {
                    "name": "Output Format",
                    "content": "The  output  is  in one of two basic formats:  a report for humans and a PPM image for use by\nprograms.  The PPM image is actually quite readable by humans too.\n"
                },
                {
                    "name": "Human Report",
                    "content": "You get this format by specifying (or defaulting to) the -nomap option.\n\nThe format is one line for each color in the input image.\n\nBy default, there are two lines of column header and a summary at the top.  Use the -noheader\noption to suppress those lines.\n\nThe summary tells you whether black or white are present and how  many  shades  of  gray  and\ncolor are present.  The summary was new in Netpbm 10.82 (March 2018).\n\n\nIn  each  line, ppmhist identifies the color by red, green, and blue components.  By default,\nit lists each of these in decimal, using the exact values that are in the PPM input.   So  if\nthe  image  has  a  maxval  of 255, the numbers in the listing range from 0 to 255.  With the"
                },
                {
                    "name": "-hexcolor  -float",
                    "content": "numbers are fractional, adjusted to a maxval of 1.\n\nEach  line  lists the luminosity of the color.  It is in decimal on the same scale as the rgb\nvalues (see above).\n\nEach line lists the number of pixels in the image that have the color.  This is in decimal.\n\n"
                },
                {
                    "name": "PPM Output",
                    "content": "You get this format with the -map option.\n\nThe output file is a genuine PPM image, but it is PPM Plain format and contains  comments  so\nthat it is not a lot different from the human report described above.\n\nAs  a  PPM image, it can be useful as input to other programs that need some kind of palette.\nThe image is a single row with one column for each distinct color in the image.\n\nThe function of PPM output is essentially the same as the output of pnmcolormap all.  ppmhist\nis much older than pnmcolormap.\n\n\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "In addition to the options common to all programs based on libnetpbm  (most  notably  -quiet,\nsee  Common Options ), ppmhist recognizes the following command line options:\n\n\n\n",
            "subsections": [
                {
                    "name": "-sort=",
                    "content": "The  -sort  option  determines the order in which the colors are listed in the output.\nrgb means to sort them first by the intensity of the red component of the color,  then\nof the green, then of the blue, with the least intense first.  frequency means to list\nthem in order of how many pixels in the input image have the color, with the most rep‐\nresented colors first.  Among colors with the same frequency, the order is the same as\nwith rgb.\n\nThe default is frequency.\n\nBefore  Netpbm  10.88 (September 2019), with -sort=frequency, the order of colors that\nhave the same frequency is arbitrary.\n\n"
                },
                {
                    "name": "-hexcolor",
                    "content": "Print the color components in hexadecimal.  See output format .\n\nYou may not specify this option along with -float or map.\n\n"
                },
                {
                    "name": "-float",
                    "content": "[0,1].  See output format .\n\nYou may not specify this option along with -hexcolor or map.\n\nThis option was added in Netpbm 10.19 (November 2003).\n\n"
                },
                {
                    "name": "-map",
                    "content": "ments.  See output format .\n\nYou may not specify this option along with -float or hexcolor.\n\n"
                },
                {
                    "name": "-nomap",
                    "content": ""
                },
                {
                    "name": "-colorname",
                    "content": "Add the color name to the output.  This is the name from the system color dictionary .\nIf the exact color is not in the color dictionary, it is the closest color that is  in\nthe dictionary and is preceded by a '*'.  If you don't have a system color dictionary,\nthe program fails.\n\nThis option was added in Netpbm 10.10 (October 2002).\n\n"
                },
                {
                    "name": "-noheader",
                    "content": "Do not print the column headings.\n\n"
                },
                {
                    "name": "-forensic",
                    "content": "With  this  option,  ppmhist works on images that contain invalid sample values.  Nor‐\nmally, like most Netpbm programs, ppmhist  fails  if  it  encounters  a  sample  value\ngreater  than  the maxval that the image declares.  The presence of such a value means\nthe image is invalid, so the pixels have no meaning.  But with -forensic, ppmhist pro‐\nduces a histogram of the actual sample values without regard  to  maxval.   It  issues\nmessages summarizing the invalid pixels if there are any.\n\nOne  use  for  this is to diagnose the problem that caused the invalid Netpbm image to\nexist.\n\nThere is a small exception to the ability of ppmhist to process  invalid  pixels  even\nwith  -forensic: it can never process a sample value greater than 65535.  Note that in\nthe rarely used Plain PPM format, it is possible for a number greater than that to ap‐\npear where a sample value belongs.\n\nThis option was new in Netpbm 10.66 (March 2014).  But Netpbm older  than  10.66  does\nnot properly reject invalid sample values, so the effect is very similar to -forensic.\n\n\n\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "ppm(1), pgmhist(1), pnmcolormap(1), pnmhistmap(1), ppmchange(1)\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Copyright (C) 1989 by Jef Poskanzer.\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/ppmhist.html\n\nnetpbm documentation                       24 August 2019                     Ppmhist User Manual(1)",
            "subsections": []
        }
    },
    "summary": "ppmhist - print a histogram of the colors in a PPM image",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The -sort option determines the order in which the colors are listed in the output. rgb means to sort them first by the intensity of the red component of the color, then of the green, then of the blue, with the least intense first. frequency means to list them in order of how many pixels in the input image have the color, with the most rep‐ resented colors first. Among colors with the same frequency, the order is the same as with rgb. The default is frequency. Before Netpbm 10.88 (September 2019), with -sort=frequency, the order of colors that have the same frequency is arbitrary."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Print the color components in hexadecimal. See output format . You may not specify this option along with -float or map."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "[0,1]. See output format . You may not specify this option along with -hexcolor or map. This option was added in Netpbm 10.19 (November 2003)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "ments. See output format . You may not specify this option along with -float or hexcolor."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Add the color name to the output. This is the name from the system color dictionary . If the exact color is not in the color dictionary, it is the closest color that is in the dictionary and is preceded by a '*'. If you don't have a system color dictionary, the program fails. This option was added in Netpbm 10.10 (October 2002)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Do not print the column headings."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "With this option, ppmhist works on images that contain invalid sample values. Nor‐ mally, like most Netpbm programs, ppmhist fails if it encounters a sample value greater than the maxval that the image declares. The presence of such a value means the image is invalid, so the pixels have no meaning. But with -forensic, ppmhist pro‐ duces a histogram of the actual sample values without regard to maxval. It issues messages summarizing the invalid pixels if there are any. One use for this is to diagnose the problem that caused the invalid Netpbm image to exist. There is a small exception to the ability of ppmhist to process invalid pixels even with -forensic: it can never process a sample value greater than 65535. Note that in the rarely used Plain PPM format, it is possible for a number greater than that to ap‐ pear where a sample value belongs. This option was new in Netpbm 10.66 (March 2014). But Netpbm older than 10.66 does not properly reject invalid sample values, so the effect is very similar to -forensic."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "ppm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ppm/1/json"
        },
        {
            "name": "pgmhist",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pgmhist/1/json"
        },
        {
            "name": "pnmcolormap",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmcolormap/1/json"
        },
        {
            "name": "pnmhistmap",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmhistmap/1/json"
        },
        {
            "name": "ppmchange",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ppmchange/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Print a histogram of the colors present in a PPM image.",
        "examples": [
            {
                "description": "Generate the histogram for human reading",
                "command": "ppmhist {{-nom|-nomap}} {{path/to/image.ppm}}"
            },
            {
                "description": "Generate a PPM file of the colormap for the image, with the color histogram as comments",
                "command": "ppmhist {{-m|-map}} {{path/to/image.ppm}}"
            },
            {
                "description": "Display version",
                "command": "ppmhist {{-v|-version}}"
            }
        ]
    }
}