# 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.

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):$

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$.

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.

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

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

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.

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.

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

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

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$.