Você está na página 1de 27

Improved Median Filtering Algorithm

With Average Filtering

Submitted to: Prepared by


Dr. Swapna Devi Mukul Chauhan
Professor(ECE) ME(Regular 2010)
ECE
Objective
• IEEE Paper
• Abstract
• Median Filtering
• Improved Median Filtering
– Improvement of the filter mask
– Improvement of the median algorithm

• Analysis of the algorithm complexity


• Simulation Experiments
• Conclusions
• References
IEEE Paper

Zhu Youlian, Huang Cheng,“An Improved Median


Filtering Algorithm Combined with Average Filtering,”
Third International Conference on Measuring
Technology and Mechatronics Automation, 2011
Abstract
• To solve the contradiction between the noise reducing
effect and the time complexity of the standard median
filter algorithm, the paper proposed an improved
median filter algorithm combined with average filtering.
According to the correlation of the image, the algorithm
adaptively resizes the filter mask according to noise
levels of the mask. According to the sorting results of
the selected pixel values in the neighborhood, the
algorithm uses the median to replace the original pixel.
Median Filtering:

• The median filtering is a non linear signal processing


technology based on statistics.
• Median filter is Used to reduce impulse noise without blurring
edges.
• It has neighborhood operation and its noise reducing effect
depends on the
 size and shape of the filter mask.
 method to find the median.
• The noisy value of a digital image or a sequence is replaced by
the median of the filter mask.
• The pixel in the mask are ranked in the order of their gray
value and the median of the mask is stored to replace the noisy
value in the mask.
The median filter output is
g(x, y)  med{ f (x  i, y  j),i, jW}
Where f(x,y) is original image.
g(x,y) is the output image.
W is a two dimensional mask.it nxn where n is
commonly odd such as 3x3,5x5 etc.The mask shape may be
square,circular cross etc.
f(1)
f1
f(2)
f2

. . f(m)
. Order . select
.
. samples
f(n) median
fN

f (1)  f (2)  f (3)   f (n)


2
m
n 1 n is odd
Example of working:
• The median is calculated by
 first sorting all the pixel values from the surrounding
neighborhood into numerical order

 replacing the pixel being considered with the middle pixel


value

fig.1:The central pixel value of 150 is rather unrepresentative of the surrounding pixels
and is replaced with the median value: 124. A 3×3 square neighborhood is used here,
larger neighborhoods will produce more severe smoothing.
Noise reducing performance of the median filter
• For an image with zero mean noise under normal distribution the
noise varience of the median filtering is approximately[1]


2
1 

2
  i
 .......... ....( 1)
mod
2

 2
4 nf (n) n 1
2


2
in
• Where is the input noise power(variance)

• n is the
 size of the median filter mask.

• f (n )
is the noise density function.
 Noise variance for average filtering.

2


2
0
 i
.......... .......... ...( 2 )
n
• It is clear from the previous two equations that median filter depends on
two things size of the mask and the distribution of the noise.
• The median filter performance of random impulse noise is better than
the average filter performance.
• The speed of the searching median people proposed some fast
algorithms based on the dividing –conquering strategy and simplified
the algorithms complexity of the standard median filter from O(n 2) to
O(nln n) given in [4] and [5].
• Further simplified the algorithm complexity to O{n(1+ln n)} in [6] but
in this case the size of the mask was fixed so noise reducing effect may
be affected when noise have same approximated same size as the filter
mask.
IMPROVED MEDIAN FILTER ALGORITHM

• Author proposed an improved median filter algorithm in which


the mask be adaptively resized according to noise density of the
mask to improve the noise reducing effect.
• The median filter performance should be improved if the median
filter algorithm combined with the average filter algorithm.
• It includes three things:
(1)Improvement of the filter mask
(2)Improvement of the median algorithm.
(3)Analysis of the algorithm complexity
Improvement of filter mask

• The filter mask is mainly a square mask(nxn) or a cross mask.


Considering of the symmetry of the mask ,n is commonly odd.
The mask size and the noise-reducing effect are a
contradiction.

• To solve contradiction ,the self adaptive filter algorithm is


introduced.

• In the filter process take the peak signal to noise ratio(PSNR)


as the target function and adaptively resize the filter mask.
• Supposing an image f(i,j) of size MxN, its output image is
fout (i,j),where i=1,2,3,…,M, j=1,2,3,..N,the mean –square
deviation (MSE) is given by the expression:
M N
1
   f out  i, j   f (i , j )  ...........................(3)
2
MSE 
M N 1 1

PSNR may be defined as


PSNR  10 log(amax
2
MSE)(dB) .........................(4)

Where amax =2k-1,k denotes the number of a pixel binary bit.


• Adaptively resizing the filter mask:
(1)use the median algorithm, filter the original image, get the
output image fn,and calculate PSNRn of fn;
(2)Let n=n+2,use the median algorithm, filter the output image fn
of step(1),get new output image fn+1 and calculate PSNRn+1 of
fn+1;
(3)If PSNRn>PSNRn+1,then maintain the size of the filter mask; if
not, then turn to step (2),and enlarge the filter mask.
Improvement of the median algorithm
• For a natural image ,neighboring pixel has strong correlation.
The gray level of each pixel is quit close to neighboring pixel
value.
• If a pixel value is greater or less than the value in
neighborhood, it signifies that the pixel is contaminated by the
noise.
• The noise reducing process consists simply of moving the
filter mask from pixel to pixel in an image.
• If the value of a pixel is greater than the average in the mask,
then the pixel is contaminated by the noise and replace it with
the median of the mask; if not maintain the original value of
the pixel unchanged.
• The improved algorithm reduce the calculation time,but also
retain the details of the image as far as possible.
• The original value of the pixel is replaced with the median in
the mask, and the next calculating process of the average may
make full use of the new pixel value.
• Due to above it also improves the noise reducing effect better.
Noise reducing Process
• Supposing a 3x3 mask is

• If mask centre f(i, j) is greater than the average,then we rank


elements in the neighborhood to obtain the median f’(i, j).
• According to the standard median algorithm,average and
median of the pixel(i, j+1) are given as
Average  { f (i  1, j)  f (i, j  1)  ... f (i  1, j  2)}/ 9..........................(5)

med  { f (i  1, j )  f (i , j  1)  ... f (i  1, j  2)}..........................(6)


• According to (5) calculate average, if f(i, j)>average,then filter
the image. Suppose filtered value is f’(i, j).then changes in to
3x3 matrix.

• Now take new mask to and new average and median are
respectively given as
Average { f (i  1, j)  ...  f ' (i, j)  f (i, j  1)  ( f (i  1, j  2)}/ 9................(6)

med  { f ( i  1, j ), f ' ( i , j ),... f ( i  1, j  2 )}........ .......... ........( 7 )


• If f(i,j+1) >average using (7,then rank to obtain the median
based on new matrix:
med  { f (i  1, j )  f ' (i , j )  ... f (i  1, j  2)}..........................(9)

• If f(i,j+1) <average ,then maintain the pixel value and process


the next pixel following the updating of part pixel values,
average of the mask is updating also .

• Where f is the original value,f’ is the updating value.


• Supposing {fi j (i,j),iƐ I2 } is the gray value of each pixel in a digital
image, the filter mask is nxn , f’ij is the median of fij in the mask,
then
f ' ij  { f ( i  r )( j  s ) ,..., f ij ,...... f ( i  r )( j  s ) }.....................(8)
f 'i( j1)  { f(ir)( js1) ,...,f 'ij ,......f(ir)( js1) }.........
..........
(9)
• So Steps of improved algorithm are below:
1. The mask slides over the image ,overlap the centre of the mask
with the pixel on the image to search the centre element f ij.
2. read the value in the mask, i.e. { f
( i  r )( j  s ) ,..., f ij ,...... f ( i  r )( j  s ) }
3. Compute average of the mask.
4. Compare the value of each pixel with average :if value of pixel
greater than average, then rank to get the median from
equation (8).at the same time the value of the pixel whose
value is less than average, if the value of the pixel is equal to
zero, then assign the median to pixel.
5. Repeat the step (4) for new pixel with equation (9).
6. Repeat the steps (4) and (5),until i=j=n
Analysis of algorithm complexity
• Improved algorithm are the same with the conventional quick
shorting algorithm. The quick shorting algorithm takes the
first as a bound to discriminate elements of the set, so the
original set is separated in to two new sets and sorting
operations are respectively operated in to two new sets.
• The improved algorithm takes as the average as the bound to
sort the set ,the next repeating sort operation always aims at
the sorted set in which the element number is greater than
N/2 and the another set in which the element number is less
is left out. The time complexity of the improved algorithm is
T f ( N )  T pass ( N )  T ( j  1).................(11)
Simulation results
• Comparative experiment among these standard median filter
algorithm ,the fast median filter algorithm based on average and
the improved algorithm in the paper.10%,30% and 45% density
impulse noise are respectively added to the original image of the
camera man. with VC++6.0,results of comparative are shown in
fig.1.
• low signal to noise ratio experiment. 60%,70%, and 80% density
impulse noise are respectively added to the original image of
flower. Results of the improved algorithm in the paper are shown
as figure 2.Experimental results show that the performance of the
improved algorithm in the paper is better than the standard
median filter algorithm and the fast median filter algorithm based
on mean in [6]. Especially in low signal to noise ratio condition,
the improved algorithm has obvious advantages.
conclusion
• The paper proposed an improved median filter algorithm for
image noise reduction. It takes the peak signal to noise ratio
(PSNR) as the target function and adaptively resizes the filter
mask according to noise levels in the mask. Combined the
median filtering with the average filtering, the improved
algorithm can reduce the noise and maintain image details
better. Experimental results show that the improved algorithm
can well do with the contradiction between the noise-reducing
effect 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 arithmetic of median filtering
denoising, Computer Engineering and Applications," 2010, vol.46, no.10, pp.187-189.
(in Chinese)
[2] Xiaokai WANG, Feng LI, "Improved adaptive median filtering,"Computer Engineering
and Applications, 2010, vol.46, no. 3, pp. 175-176. (in Chinese)
[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. (in Chinese)
[5] Huang T S, Tang G T, "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. (in Chinese)
[7] Tingbiao CHEN, Liangzheng XIA, "Digital image processing,"Beijing: Posts &
Telecommunications Press, 1994. (in Chinese)
THANK YOU

Você também pode gostar