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)

    Wise Draco comes, deep in the midnight roll
    Of black artillery; he comes, though late;
    In code corroborating Calvin’s creed
    And cynic tyrannies of honest kings;
    He comes, nor parlies; and the Town, redeemed,
    Gives thanks devout; nor, being thankful, heeds
    The grimy slur on the Republic’s faith implied,
    Which holds that Man is naturally good,
    And—more—is Nature’s Roman, never to be
    scourged.
    Herman Melville (1819–1891)