Selected median filters

Image filtering is often applied as a post–process to an image in order to reduce noise. The usage of smoothing filters such as median may reduce noise. Unfortunately, these filters, apart from noise reduction, also introduce some distortions. I present the usage of a few median type filters.

Here, I present a view from my home. I called this image 'secret garden'. I don't use the most popular images (like 'Lena'), because its use isn't obvious. On the left is the original image, on the right with impulse noise. In all simulations, I used 8-bit mono images of dimension M\times N  (512\times512) pixels with added impulse noise with density value 0.05.

secret_garden_bk    secret_garden_noise_s&p_05

The standard median filter (SM) is a simple non-linear smoothing operation that takes a median value of the data inside a moving (2K+1)\times(2K+1) square window centred at the pixel (i, j):

 y(i,j) = median \{\, x(i+s, j+t ),

-K \le s \le K,\,-K \le t \le K \, \},

where x(i, j) and y(i, j) are the input and output of median filter respectively. Below, there are two images, on the left original image with added noise, on the right with applied SM filter for K=1.

secret_garden_noise_s&p_05    mf_secret_garden_3x3

Another commonly used filter is a star-shaped median filter (SSM) in which the filter output is defined as median of considered pixel and its four neighbours.

 y(i,j) = median \{\, x(i-1,j), x(i,j-1), x(i, j), x(i, j+1), x(i+1, j) \} \,.

Here, I present the usage of SSM filter for  K=1.

secret_garden_noise_s&p_05    smf_secret_garden_3x3

Weighted median filter (WM) is an extension of median filter, which gives more weight to some values within the window.

 y(i,j) = median \{\, w(i+s,j+t) \Diamond x(i+s,j+t)\} \, ,

-K \le s \le K,\,-K \le t \le K \, \} ,

where  w(i, j) denotes weights for x(i, j) image coordinates and \Diamond denotes duplication procedure.

A special case of WM filter is a centre-weighted median filter (CWM), in which more weight to the central value of a window is given. By adjusting the weight coefficients, it is possible to suppress the noise.

 y(i,j) = median \{\, w(i+s,j+t) \Diamond x(i+s,j+t)\} ,

w(s,t) = \begin{cases} 2L+1, & for \, s=0, t=0 \\ 1, & for \, s \ne 0, t \ne 0 \end{cases}

-K \le s \le K,\,-K \le t \le K \, \} ,

where L is non-negative integer. When L=0, the CWM filter becomes the standard median filter.

I show the usage of CWM filter for K=1 and for L=0,1,2 respectively.

secret_garden_noise_s&p_05    cwmf_secret_garden_3x3w3

cwmf_secret_garden_3x3w5    cwmf_secret_garden_3x3w7

Here, I present the usage of CWM filter for K=2 and for L=0,1,2 respectively.

secret_garden_noise_s&p_05    cwmf_secret_garden_5x5w3

cwmf_secret_garden_5x5w5    cwmf_secret_garden_5x5w7

Multistage median filter (MM) based on applying different subsets of pixels within a 2-D moving window:

 y(i,j) = median \{\, x(i+s, j+t ),

-K \le s \le K,\,-K \le t \le K \, \} ,

 y(i,j) = median \{\, y_1(i, j), y_2(i,j), x(i, j) \,\} ,

 y_1 = min\{\, z_1(i, j), z_2(i, j), z_3(i, j), z_4(i, j)\} ,

 y_2 = max\{\, z_1(i, j), z_2(i, j), z_3(i, j), z_4(i, j)\, \} ,

 z_1 = median\{\, x(i, j+k), \, -K \le k \le K \,\} ,

 z_2 = median\{\, x(i+k, j+k), \, -K \le k \le K \,\} ,

 z_3 = median\{\, x(i+k, j-k), \, -K \le k \le K \,\} ,

 z_4 = median\{\, x(i+k, j), \, -K \le k \le K \,\} ,

where z_k(i ,j) values with k=1,2,3,4 are median values of elements set inside (2K+1)\times(2K+1) square window.

Finally, I present MM filter for K=1.

secret_garden_noise_s&p_05    mmf_secret_garden_3x3

For more information, please check in following books and articles:

1. William K. Pratt, Digital Image Processing, 2001
2.Rafael C. Gonzalez, Richard E. Woods, Digital Image Processing, Addison-Wesley Publishing Company, 1993
3. L. Yin, R. Yang, M. Gabbouj, Y.Neuvo, Weighted Median Filters: a Tutorial, IEEETransactions On Circuits and Systems – II:    Analog and Digital Signal Processing, vol. 43, No. 3, March 1996, pp. 157-192.
4. Sung-Jea Ko, Yong Hoon Lee,  Center weighted median filters and their applications to image enhancement, IEEE Transactions on Circuits and Systems, Volume: 38, Issue: 9, September 1991.
5. X. Wang, Adaptive Multistage Median Filter,IEEE Transactions on Signal Processing, vol.40, No 4, April 1992.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>