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)

    Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a “sock” in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.
    George Bernard Shaw (1856–1950)