PGMMEDIAN(1)

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

πŸ’– PGMMEDIAN β€” okay bestie, let's talk median filters πŸ’–

So the manual name situation is Pgmmedian User Manual(1), from the General Commands Manual section, and it's giving image smoothing but make it aesthetic. Welcome to the group chat 🫢

✨ NAME ✨

pgmmedian β€” applies a median filter to a PGM file. That's it, that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

pgmmedian

[-width=n]

[-height=n]

[-type=median_type]

[-cutoff=int]

[pnmfile]

Okay so real talk about the syntax rules, because they're lowkey generous:

  • Minimum unique abbreviation of option is acceptable. Type less, slay more. πŸ’…
  • You may use double hyphens instead of single hyphen to denote options. Both work bestie, we don't gatekeep.
  • You may use white space in place of the equals sign to separate an option name from its value. Spaces are valid separators, periodt.

πŸ¦‹ DESCRIPTION πŸ¦‹

This program is part of Netpbm(1). Iconic family tree, no cap. πŸ‘‘

pgmmedian applies a median filter to a PGM image, using either the histogram sort or select kth value method to determine the median. Two methods, one queen behavior.

So what even is a median filter, you ask? It's a convolution filter where the value of a pixel in the output is the median of a certain set of pixels in the neighborhood of the corresponding input pixel. The whole effect is that it eliminates locally extreme values. Those pixels typically show up as speckles β€” yes, that's the noise on your pretty little image, and we're handling it. 🧚✨

Now the part where the edges get special treatment: pixels at the edges of the image β€” like, pixels where the convolution kernel would go off the edge of the image β€” are just copied. Not filtered. Just copied. For example, if -height is 9, the first 4 and last 4 rows of the input image are just copied to the output. They don't get the glow-up, they just get skipped, and honestly? Relatable. πŸ’€

For how pgmmedian decides between the two methods, go read the -type and -cutoff options. Everything is explained there, iykyk.


⭐ OPTIONS ⭐

On top of the options common to all programs based on libnetpbm (most notably -quiet, see Common Options), pgmmedian recognizes the following command line options:

  • -cutoff int β€” this option provides the cutoff value that pgmmedian uses to decide between using the histogram sort or select kth value method to find the median.

Okay so here's the formula, bestie, write it down: if (maxval / ((width * height) - 1)) β€” where maxval is the maxval of the image and width and height are the dimensions of the mask β€” is less than the cutoff value, pgmmedian uses histogram sort. Otherwise, it uses kth value. Simple as that. 🌈

Heads up though: this option has no effect if you specify -type. They don't co-exist, it's a one-or-the-other situation. πŸ™ˆ

The default is 250.

  • -width=n β€” Width of the median mask to apply. Maximum allowed is the width of the input image. Default is 3. Little baby default, we love a modest start.
  • -height=n β€” Height of the median mask to apply. Maximum allowed is the height of the input image. Default is 3. Matching 3, symmetric queen behavior. πŸ‘‘
  • -type median_type β€” this option selects which method to use to find median regardless of cutoff value. Choices are histogram_sort and select. It overrides everything, it's the main character here.

By default, pgmmedian decides which method to use as described under the -cutoff option.


πŸ“š REFERENCES πŸ“š

  • "Collected Algorithms from ACM" Volume II, Algorithm 489 by Robert W. Floyd
  • "A Fast Two-Dimensional Median Filtering Algorithm" in "IEEE Transactions on Acoustics, Speech, and Signal Processing" Vol. ASSP-27, No. 1, February 1979
  • "Digital Image Processing Algorithms" by Ioannis Pitas, Prentice Hall, 1993 ISBN 0-13-145814-0

Academic royalty, we love to see it. πŸŽ“βœ¨


πŸ‘€ SEE ALSO πŸ‘€

pgmnoise(1), pamaddnoise(1), pnmconvol(1), pgmmorphconv(1), pgm(1)

Go read those too, they're all part of the same friend group πŸ’œ


πŸ’œ HISTORY πŸ’œ

pgmmedian was added to Netpbm in Version 10.29 (August 2005). It had been distributed by Mike Burns via his own web site before that (and continued to be so). From personal website to Netpbm canon, that's a glow-up. πŸ”₯


πŸŽ€ AUTHOR πŸŽ€

Copyright (C) 1996 by Mike Burns <burns@cac.psu.edu>


🌟 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/pgmmedian.html

And that's the whole page, bestie! Netpbm documentation, dated 20 January 2022, footer reads Pgmmedian User Manual(1) πŸ’– You're officially a median filter expert, no cap. Go smooth some speckles. βœ¨πŸ¦‹πŸ“πŸ’…
πŸ“¦ where this page comes from