PGMHIST(1)

πŸ“¦
version 11.13.03 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… PGMHIST β€” like, the PGM histogram page, bestie

okay so this is pgmhist(1) from the Pgmhist User Manual and honestly? it's giving data girlie. she reads your PGM image and tells you everything about its gray values. we love a metrics queen. πŸ‘‘


✨ NAME ✨

pgmhist β€” prints a histogram of the values in a PGM image πŸŽ€


🌸 SYNOPSIS 🌸

pgmhist

[-median, -quartile, -decile]

[-forensic]

[-machine]

[pgmfile]

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first things first: this program is part of Netpbm(1). family business. πŸ’–

pgmhist reads a PGM image as input and prints a histogram of the gray values, or honestly any of the other gray value distribution metrics, whichever vibe you're going for.

if you specify none of -median, -quartile, or -decile, then pgmhist prints a complete histogram showing how many pixels of each possible gray value exist in the image. and like, along with each gray value, it also tells you how many pixels are at least as black as it, and how many are at least as white. so helpful. so thorough. no cap. ✨

the -median, -quartile, and -decile options make pgmhist print the indicated quantiles instead. and here's the thing β€” each quantile is a gray value that actually appears in the image (as opposed to those fractional values that are sometimes used for quantiles, which, no shade, but we're not doing that here). so:

  • 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

periodt. 🌈


πŸŽ€ OPTIONS πŸŽ€

on top of the options that are common to all programs based on libnetpbm (most notably -quiet, see Common Options), pgmhist also recognizes these command line options, bestie:

🚨 real talk: you may specify at most one of -median, -quartile, and -decile. if none of these is specified, pgmhist prints a histogram of gray values. that's the default. main character behavior.
  • -median β€” makes pgmhist print the median gray value. πŸ“Š

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

  • -quartile β€” makes pgmhist print the four quartile gray values. πŸ“

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

  • -decile β€” makes pgmhist print the ten decile gray values. πŸ”₯

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

  • -forensic β€” with this option, pgmhist will work 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. and like, the presence of such a value means the image is invalid, so the pixels have no meaning. 😭 but with -forensic, pgmhist produces a histogram of the actual gray values without regard to maxval. it also issues messages summarizing the invalid pixels if there are any. very detective. very slay.

one use for this is to diagnose the problem that caused the invalid Netpbm image to exist in the first place. iykyk. πŸ•΅οΈ

⚠️ 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 appear where a gray value belongs. so. heads up.

this option was new in Netpbm 10.66 (March 2014). but β€” plot twist β€” Netpbm older than 10.66 does not properly reject invalid sample values, so the effect is very similar to -forensic. πŸ’€

  • -machine β€” makes pgmhist print the information in a way that's 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 β€” yes, even the ones that ghosted, we still list them πŸ’œ), 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 decimal numbers without leading zeroes.

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


πŸ‘€ SEE ALSO πŸ‘€

pnmnorm(1), ppmhist(1), pgm(1)


πŸ’– 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

and that's the whole thing bestie!! 🫢 netpbm documentation, dated 18 December 2021, straight from the Pgmhist User Manual β€” go forth and histogram responsibly. mwah. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from