# pgmhist - print a histogram of the values in a PGM image - man - [phpMan]

> **TLDR:** Print a histogram of the values present in a PGM image.
>
- Display the histogram for human reading:
  `pgmhist {{path/to/image.pgm}}`
- Display the median grey value:
  `pgmhist {{-me|-median}} {{path/to/image.pgm}}`
- Display the four quartile grey values:
  `pgmhist {{-qua|-quartile}} {{path/to/image.pgm}}`
- Report the existence of invalid grey values:
  `pgmhist {{-f|-forensic}} {{path/to/image.pgm}}`
- Display machine-readable output:
  `pgmhist {{-ma|-machine}} {{path/to/image.pgm}}`

*Source: tldr-pages*

---

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

## NAME
       pgmhist - print a histogram of the values in a PGM image


## SYNOPSIS
### pgmhist

       [**-median**, **-quartile**, **-decile**]

       [**-forensic**]

       [**-machine**]

       [_pgmfile_]


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

       **pgmhist  **reads  a  PGM image as input and prints a histogram of the gray values or other gray
       value distribution metrics.

       If you specify none of **-median**, **-quartile**, or **-decile**, **pgmhist **prints  a  complete  histogram
       showing how many pixels of each possible gray value exist in the image.  Along with each gray
       value,  it  tells you how many pixels are at lest as black as it and how many are at least as
       white.

### -median -quartile -decile 
       tiles.  Each quantile is a gray value that actually appears in the image (as opposed to frac‐
       tional  values  that  are  sometimes used for quantiles).  The 3rd quartile is the least gray
       value for which at least 75% of the pixels are as dark or darker than it.  The  4th  quartile
       is the brightest gray value that appears in the image.



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

       You may specify at most one of **-median**, **-quartile**, and **-decile**.  If none of these  is  speci‐
       fied **pgmhist **prints a histogram of gray values.



### -median

              This option causes **pgmhist **to print the median gray value.

              This option was new in Netpbm 10.61 (December 2012).


### -quartile

              This option causes **pgmhist **to print the four quartile gray values.

              This option was new in Netpbm 10.61 (December 2012).


### -decile

              This option causes **pgmhist **to print the ten decile gray values.

              This option was new in Netpbm 10.61 (December 2012).


### -forensic

              With this option, **pgmhist **works on images that contain invalid gray values.  Normally,
              like  most  Netpbm  programs, **pgmhist **fails if it encounters a gray 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**, **pgmhist **produces a his‐
              togram of the actual gray values without regard to maxval.  It issues messages  summa‐
              rizing 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 **pgmhist **to process  invalid  pixels  even
              with  **-forensic**:  it  can never process a gray value greater than 65535.  Note that in
              the rarely used Plain PGM format, it is possible for a number greater than that to ap‐
              pear where a gray 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**.


### -machine

              This  option  causes  **pgmhist **to print the information in a way easily digestible by a
              machine as opposed to a human.

              For the quantiles, there is one line per quantile, in quantile order, and it  consists
              of the gray value of the quantile in decimal with no leading zeroes.

              For  the  full  histogram  output,  it  consists  of  one line per possible gray value
              (whether that value appears in the image or not), in order of the  gray  values.   The
              line  consists  of  two tokens separated by a space.  The first is the gray value; the
              second is the number of pixels in the image that have that gray value.  Both are deci‐
              mal numbers without leading zeroes.

              This option was new in Netpbm 10.61 (December 2012).





## SEE ALSO
       [**pnmnorm**(1)](https://www.chedong.com/phpMan.php/man/pnmnorm/1/markdown), [**ppmhist**(1)](https://www.chedong.com/phpMan.php/man/ppmhist/1/markdown), [**pgm**(1)](https://www.chedong.com/phpMan.php/man/pgm/1/markdown)


## AUTHOR
       Copyright (C) 1989 by Jef Poskanzer.

## 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/pgmhist.html>**

netpbm documentation                      18 December 2021                    _Pgmhist_ _User_ [_Manual_(1)](https://www.chedong.com/phpMan.php/man/Manual/1/markdown)
