# Median and Nth Order Filtering

Publish Date: Sep 06, 2006 | 2 Ratings | 4.00 out of 5 | Print

### 1. Description

Median filtering is a non-linear, low-pass filtering method, which you use to remove "speckle" noise from an image. A median filter can outperform linear, low-pass filters on this type of noisy image because it can potentially remove all the noise without affecting the "clean" pixels. A linear filter will also reduce the noise, but by spreading out the effects of noisy pixels rather than isolating and removing them.

To understand how this works, we'll look at Nth Order filters (from the IMAQ Vision User Manual):

The Nth order filter is an extension of the median filter. It assigns to each pixel the Nth value of its neighborhood (when sorted in increasing order). The value N specifies the order of the filter, which you can use to moderate the effect of the filter on the overall light intensity of the image. A lower order corresponds to a darker transformed image; a higher order corresponds to a brighter transformed image.

Each pixel is assigned the Nth value of its neighborhood, N being specified by the user.

P(i, j) = Nth value in the series [P(n, m)]

where the P(n, m) are sorted in increasing order.

The following example uses a 3 × 3 neighborhood:

 P(i-1, j-1) P(i, j-1) P(i+1, j-1) P(i-1, j) P(i, j) P(i-1, j) P(i-1, j+1) P(i, j+1) P(i+1, j+1)

=

 13 10 9 12 4 8 5 5 6

The following table shows the new output value of the central pixel for each Nth order value:

 Nth Order 0 1 2 3 4 5 6 7 8 New Pixel Value 4 5 5 6 8 9 10 12 13

Notice that for a given filter size f, the Nth order can rank from 0 to f2 – 1. For example, in the case of a filter size 3, the Nth order ranges from 0 to 8 (32 – 1).
A 3x3 median filter would just be the 4th order filter, with N given by (f2-1)/2.

Low order filters tend to erode bright regions and dilate dark regions; high order filters have the opposite effect. Median filters remove isolated pixels, whether they are bright or dark.

### 2. Common Applications

Common applications include:
• Removal of speckle noise
• Enhancement of bright or dark features in an image

### 3. What To Expect

A denoised, enhanced image