Median Filter - 2D Median Filter Pseudo Code

2D Median Filter Pseudo Code

Code for a simple 2D median filter algorithm might look like this:

allocate outputPixelValue edgex := (window width / 2) rounded down edgey := (window height / 2) rounded down for x from edgex to image width - edgex for y from edgey to image height - edgey allocate colorArray for fx from 0 to window width for fy from 0 to window height colorArray := inputPixelValue sort all entries in colorArray outputPixelValue := colorArray

Note that this algorithm:

  • Processes one color channel only,
  • Takes the "not processing boundaries" approach (see above discussion about boundary issues).

Read more about this topic:  Median Filter

Famous quotes containing the words pseudo and/or code:

    Logic is the last scientific ingredient of Philosophy; its extraction leaves behind only a confusion of non-scientific, pseudo problems.
    Rudolf Carnap (1891–1970)

    Acknowledge your will and speak to us all, “This alone is what I will to be!” Hang your own penal code up above you: we want to be its enforcers!
    Friedrich Nietzsche (1844–1900)