Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Available online at www.sciencedirect.

com

Physics Procedia 25 (2012) 609 – 616

2012 International Conference on Solid State Devices and Materials Science

An Improved Median Filtering Algorithm for Image Noise


Reduction *
Youlian Zhu, Cheng Huang
College of Electronic Information Engineering
Jiangsu Teachers University of Technology
Changzhou, China, 213001

Abstract

The median filtering algorithm has good noise-reducing effects, but its time complexity is not desirable. The paper
proposed an improved median filtering algorithm. The algorithm uses the correlation of the image to process the
features of the filtering mask over the image. It can adaptively resize the mask according to noise levels of the mask.
The statistical histogram is also introduced in the searching process of the median value. Experimental results show
that the algorithm reduces the noise and retains the details of the image. The complexity of the algorithm is decreased
to O (N), and the performance of noise reduction has effectively improved.

2011 Published by
© 2012 by Elsevier
Elsevier Ltd.
B.V.Selection
Selectionand/or
and/orpeer-review
peer-reviewunder
underresponsibility ofof
responsibility [name
Garryorganizer]
Lee
Open access under CC BY-NC-ND license.
Keywords: Image Processing; Median Filtering; Adaptive Filtering; Statistical Histogram

1. Introduction

Noises may be arisen in the capturing and transmission process of the image. The noise is usually
divided into Gaussian noise, the balanced noise and the impulse noise. The arisen impulse noises display as
light and dark noise pixels under random distribution on the image. This not only corrupts true information
of the image, but also seriously affects the visual effects of the image. Therefore, the reduction of impulse
noises has important significance to image processing and computer vision analysis.
For an image corrupted by noises, we can use linear or nonlinear filter methods to reduce noises. In the
frequency domain, the details are high-frequency components of the image, which easily confused with
high-frequency noises. Therefore, how to keep the image details and effectively filter random noises is the
key to image filtering processing. The median filter is a nonlinear filter and it has widely used in digital
image processing because of its good edge keeping characteristics and reducing impulse noise ability. The
median filter is a rank-order filter. Its noise-reducing effects depend on the size and shape of the filtering
*
This work is substantially supported by natural science fund # KYY09020 from Jiangsu Teachers University of Technology

1875-3892 © 2012 Published by Elsevier B.V. Selection and/or peer-review under responsibility of Garry Lee
Open access under CC BY-NC-ND license. doi:10.1016/j.phpro.2012.03.133
610 Youlian Zhu and Cheng Huang / Physics Procedia 25 (2012) 609 – 616

mask; and its algorithm complexity mainly depends on how to get the median value. In order to improve
the noise-reducing performance of the median filter, scholars proposed many improved methods to the
conventional median filter [1-3]. To improve the searching speed of the median value, people proposed some
fast algorithms based on the dividing-conquering strategy, and simplified the algorithm complexity of the
conventional median filter from O (N2) to O (n ln n) in references [4] and [5]. The prophase work [6] of the
paper further simplified complexity to O (n(1+ln n) /2). Based on the prophase study, this paper proposed
two improvements to the median filtering algorithm:
(1) To improve the noise-reducing performance, the mask may be adaptively resized according to noise
levels of the mask;
(2) According to the median filtering theory, we only require quickly find the median value of the
filtering mask, and not to rank all the pixels of the filtering mask. Therefore, the statistical histogram is
introduced in the searching process of the median value to speed up the searching process.

2. Median filtering Theory

The median filter is a nonlinear signal processing technology based on statistics. The noisy value of the
digital image or the sequence is replaced by the median value of the neighborhood (mask). The pixels of
the mask are ranked in the order of their gray levels, and the median value of the group is stored to replace
the noisy value. The median filtering output is g ( x, y ) med{ f ( x  i, y  j ), i, j  W } , where f ( x, y ),
g ( x, y ) are the original image and the output image respectively, W is the two-dimensional mask: the mask
size is n u n(where n is commonly odd) such as 3 u 3, 5 u 5, and etc.; the mask shape may be linear, square,
circular, cross, and etc.

The noise-reducing performance of the median filter:


Because the median filter is a nonlinear filter, its mathematical analysis is relatively complex for the
image with random noise. For an image with zero mean noise under normal distribution, the noise variance
of the median filtering is approximately [7]

2 1 Vi 2 S
V med | ˜ ѽҏ (1)
4n f 2 ( n) S 2
n 1
2

where V i2 is input noise power (the variance), n is the size of the median filtering mask, f (n ) is the
function of the noise density. And the noise variance of the average filtering is

1 2
V 02 V i ѽҏ (2)
n

Comparing of (1) and (2), the median filtering effects depend on two things: the size of the mask, and
the distribution of the noise. The median filtering performance of random noise reduction is better than the
average filtering performance, but to the impulse noise, especially narrow pulses are farther apart and the
pulse width is less than n / 2 , the median filter is very effective. The median filtering performance should
be improved if the median filtering algorithm, combined with the average filtering algorithm, can
adaptively resize the mask according to the noise density. Based on this, the paper proposed an improved
median filtering algorithm.
Youlian Zhu and Cheng Huang / Physics Procedia 25 (2012) 609 – 616 611

3. Improved Median Filtering Algorithm

A. Improvement of the filtering mask


The filtering mask is mainly n u n square mask or cross mask. Considering of the symmetry of the
mask, n is commonly odd. The smaller the mask is, the better the image details are retained, the weaker the
noise reduction performance is; the larger the mask is, the less the image details are retained, the stronger
the noise reduction performance is. To solve the contradiction, we introduce the adaptive filtering
algorithm. In the filtering process, it can adaptively resize the mask according to noise levels of the mask.
In the mask, max is the maximum value of gray levels, min is the minimum value of gray levels,
average is the average value of gray levels, med is the median value of gray levels, f (i, j ) is the central
value of the mask, n is the size of the mask. The adaptive filtering requires two steps:
Step 1: adaptively resizing the mask
(1) Initialization: let n 3 ;
(2) Computation: A1 med  min, A2 med  max
(3) Judgment: if A1 ! 0 and A2  0 , then turn to the step 2; if not, then enlarge the size of the mask,
let n n  2 and turn to (2).
Step 2: median filtering.

B. Improvements of the median algorithm


Because the average filter has better performance for filtering random noises, we combine the median
filter with the average filter to certain size of the filtering mask. The improved method can reduce noises
and retain the image details better.

Improving ideas:
For the natural image, neighboring pixels has strong correlation. The gray value of each pixel is quite
close to neighboring pixels, and the edge pixels have the same property also. If the value of a pixel is
greater or less than the value in the neighborhood, the pixel is contaminated by the noise; otherwise, the
pixel is an available pixel. In the reducing-noise process, we sequentially check each pixel, if the value of a
pixel is greater than the average value in the mask, then we judge that the pixel is contaminated by the
noise and replace it with the median value of the mask; otherwise, we retain the original value of the pixel
unchanged. This method not only reduces the computation time, but also retains the details of the image as
far as possible. The original value of the pixel is replaced with the median value in the mask, and the next
process of computation the average value may make full use of the new value of the pixel. This forms an
iterative process; it not only decreases the time complexity, but also improves the noise-reducing effect
better.

For example: reducing-noise of the pixel (i, j ) , the neighborhood size is 3 u 3 .


If f  average ! 0 , then the median value is f / (i, j ) . If f / (i, j )  f (i, j ) , then f / (i, j ) is the noise.
By the conventional algorithm, the average and median value of the pixel (i, j  1) are respectively

Average { f (i  1, j )  " f (i, j )


ҏ (3)
 f (i, j  1)  " f (i  1, j  2)} / 9
612 Youlian Zhu and Cheng Huang / Physics Procedia 25 (2012) 609 – 616

Med { f (i  1, j )  " f (i, j )


ҏ (4)
 f (i, j  1)  " f (i  1, j  2)}

If f (i, j ) is replaced by the factor of improved algorithm f ' (i, j ) , the average and median value are
respectively

average { f (i  1, j )  " 
/ ҏ (5)
f (i, j )  f (i, j  1)  " f (i  1, j  2)} / 9

med { f (i  1, j )  " 
/ ҏ (6)
f (i, j )  f (i, j  1)  " f (i  1, j  2)}

According to f / (i, j )  f (i, j ) ˈ average is less than Average. Thus, the spatial extent of the noise
reduction is increase, and the time complexity of the improved algorithm is less than the conventional
algorithm. Steps of the improved algorithm are shown as below.
(1) The mask slides over the image, overlaps the center of the mask with the pixel on the image to
search the center element f (i, j ) ;
(2) To read the values of the corresponding pixels of the mask;
(3) To compute the average value (average) of the mask;
(4) To compare the value of each pixel with average, if the value of each pixel is greater than average,
then searching the median value and let f (i, j ) med ; otherwise, retaining the original value of the pixel
unchanged;
(5) Repeating the step (4), until i j n .

Fast computation of the median value:


The complexity of the algorithm is mainly decided by the computation of the median value on above
steps. The paper introduces the statistical histogram to improve the searching speed of the median value.
The method requires below steps:
(1) To compute the gray histogram hist[i ] (0<i<G, where G is the range of the gray) of the n u n mask,
let N n u n , find the median value med , and record ltmed (the number of the pixel value which is less
than med );
(2) To let the left row shift out of the histogram, if the value of the shifting out pixels is less than med ,
then ltmed  1 ;
(3) To let the right row shift in the histogram, if the value of the shifting in pixels is less than med ,
then ltmed  1 ;
(4) If ltmed  N / 2 , then repeat med  1 , ltmed  hist[med ] , until ltmed N / 2 ;
(5) If ltmed ! N / 2 , then repeat med  1 , ltmed  hist[med ] , until ltmed N / 2 ;
(6) To return the median value med .
The improved algorithm has two improvements compared to the conventional median filtering
algorithm. One is to make the number of the compared pixels equal to N by using the historical
information of the sliding mask, and the value of each pixel always compares to the original median value
Youlian Zhu and Cheng Huang / Physics Procedia 25 (2012) 609 – 616 613

of the mask. Another is to make the complexity of the median algorithm decrease greatly by using the
characteristic of the limited gray-level distribution range.

C. Analysis of the complexity of the algorithm


Suppose X = {Xi} (i=1, 2, … , N ) is the array to solve the median value, where 0 d xi d M and xi is
integer. By using the statistical histogram method to find the median value, the required maximum number
is N, and the complexity of the algorithm is approximately O (N).
TABLE I Comparison of the Complexities of Three Algorithms

the standard median filtering the fast median filtering algorithm based on the improved algorithm in the
Size of the algorithm average paper
mask
N ln N N (1+lnN)/2 N
3u3 19 14 9
5u5 80 52 25
7u7 190 119 49
9u9 355 218 81
11 u 11 580 350 121

According to TABLE I, the computation complexity of the improved algorithm is obviously reduced.

4. Simulation Experiments

Experiment 1: comparative experiment among the standard median filtering algorithm, the fast median
filtering algorithm based on average and the improved algorithm in the paper.
10%, 35%, and 45% density impulse noises are respectively added to the original image of Lena. With
VC++6.0, results of the comparative experiment are shown as Fig. 1.

(a) Original image of Lena

(b1) 10% ( b2) 35% (b3 ) 45%


Lena image with the impulse noises
614 Youlian Zhu and Cheng Huang / Physics Procedia 25 (2012) 609 – 616

(c1) (c2) (c3)


Results of the standard median filtering algorithm

(d1) (d2) (d3)


Results of the fast median filtering algorithm based on average

(e1) (e2) (e3)


Results of the improved algorithm in the paper

Fig. 1 Comparative experiment

Experiment 2: low signal to noise ratio experiment.


60%, 70%, and 80% density impulse noises are respectively added to the original image of Lena.
Results of the improved algorithm in the paper are shown as Fig. 2.
Youlian Zhu and Cheng Huang / Physics Procedia 25 (2012) 609 – 616 615

(a1) 60% (a2) 70% (a3) 80%

(b1) (b2) (b3 )

Fig. 2 low signal to noise ratio experiment results of the improved algorithm

Performance estimation:
The effect of the image noise reduction may estimated by the subjective visual effect or the objective
estimation method. The paper takes the peak signal to noise ratio (PSNR) and the signal to noise ratio (SNR)
as the performance estimation standard.
Suppose an original image is f (i, j ) and its size is M u N , the processed image is f OUT (i, j ) and its size
is M u N , where i 1,2,..., M , j 1,2,..., N , then we have

1 MN
MSE
2
¦¦ ( fOUT (i, j ) f (i, j )) ѽҏ (7)
M uN i j

2
a max
PSNR 10 lg( )(dB) ѽҏ (8)
MSE

M N
2
¦¦ f (i, j )
SUM
i j ѽҏ (9)
M N 2
¦¦ ( f OUT ( i , j )  f ( i , j ))
i j

SNR 10 lg(SUM )(dB) ѽҏ (10)


616 Youlian Zhu and Cheng Huang / Physics Procedia 25 (2012) 609 – 616

where amax 2k  1 , k denotes the number of a pixel binary bit. If k =8, then amax 255 . The results of two
experiments are shown in the TABLE II.
Experimental results show that the performance of the improved algorithm in the paper is better than
the standard median filtering algorithm and the fast median filtering algorithm based on average.
Especially in low signal to noise ratio condition, the improved algorithm has obvious advantages.
TABLE II Comparison of the Performance of Three Algorithms

the fast median the improved


the standard median
Noise filtering algorithm algorithm in the
filtering algorithm
density based on average paper
PSNR(dB) SNR(dB) PSNR(dB) SNR(dB) PSNR(dB) SNR(dB)
10% 31.2439 25.5618 31.3804 25.6983 32.1180 26.1059
35% 28.7432 22.0611 28.8262 22.1441 31.8541 25.1720
45% 16.9419 11.2598 17.3371 11.6550 30.5521 23.8699
60% ü ü ü ü 28.5861 21.6371
70% ü ü ü ü 27.2651 20.3327
80% ü ü ü ü 26.1206 19.1103

5. Conclusions

The paper proposed an improved median filtering algorithm for image noise reduction. It can
adaptively resize the mask according to noise levels of the mask. Combined the median filtering with the
average filtering, the improved algorithm can reduce the noise and retain the image details better. The
statistical histogram is introduced to improve the searching speed of the median value and the correlation
of image has been fully used. Thus, the complexity of the improved algorithm is decreased to O (N).
Experimental results show that the improved algorithm can well do with the relationship between the effect
of the noise reduction and the time complexity of the algorithm. Therefore, it has a good application
prospect in image processing.

References

[1] Guohong Liu, Wenming Guo, "Application of improved arthmetic of median filtering denoising, Computer Engineering
and Applications," 2010, vol.46, no.10, pp.187-189.
[2] Xiaokai Wang, Feng Li, "Improved adaptive median filtering," Computer Engineering and Applications, 2010, vol.46, no.
3, pp. 175-176.
[3] Chao Wang, Zhongfu Ye, "Salt-and-pepper noise removal by adaptive median filter and TV inpainting," Journal of
University of Science and Technology of China, 2008, vol.38, no. 3, pp. 282-287.
[4] Qinghua Huang, Heqin Zhou, Huanqing Feng, "A fast and effective algorithm of pulse noise filtering for imaging data,
"Computer Engineering and Applications, 2002, no. 17, pp. 113- 114, 210.
[5] T S Huang, G T Tang, "A fast two- dimensional median filtering algorithm," IEEE Trans Acoustics, Speech, and Signal
Processing, 1979, vol.27, no. 1, pp. 13- 18.
[6] Chubin Wu, "The fast algorithm of medium filtering based on mean," Journal of Jiangsu Teachers University of
Technology, 2006, vol.12, no.6, pp. 102-106.
[7] Tingbiao Chen, Liangzheng Xia, "Digital image processing," Beijing: Posts & Telecommunications Press, 1994.

You might also like