PGMMEDIAN(1)
π 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:
-cutoffint β this option provides the cutoff value thatpgmmedianuses 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 is3. 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 is3. Matching 3, symmetric queen behavior. π-typemedian_type β this option selects which method to use to find median regardless of cutoff value. Choices arehistogram_sortandselect. 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, dated20 January 2022, footer readsPgmmedian User Manual(1)π You're officially a median filter expert, no cap. Go smooth some speckles. β¨π¦ππ
π¦ where this page comes from
- debian bookworm: netpbm 2:11.01.00-2 Β· MIT
- debian trixie: netpbm 2:11.10.02-1 Β· MIT
- ubuntu noble: netpbm 2:11.05.02-1.1build1 Β· MIT
- ubuntu resolute: netpbm 2:11.10.02-1build1 Β· MIT
- ubuntu stonking: netpbm 2:11.13.03+ds-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms