Sie sind auf Seite 1von 5

Adaptive Median Filter

Purpose: want to remove impulse noise while preserving edges


Algorithm: Level A: A1= zmedian – zmin
A2= zmedian – zmax
If A1 > 0 and A2 < 0, goto level B
Else increase window size
If window size <= Smax repeat level A
Else return zxy
Level B: B1= zxy – zmin
B2= zxy – zmax
If B1 > 0 and B2 < 0, return zxy
where zmin = minimum Else
gray return zmedianin Sxy
level value
zmax = maximum gray level value in Sxy
zmedian = median of gray levels in Sxy
zxy = gray level value at pixel (x,y)
Adaptive Median Filter: How it works

• We start by considering only the immediate neighbors of the


current pixel, a window size of 3×3.

• The purpose of Level A is to determine if the standard median


filter output is impulse noise for this initial window.
• If it equals the MAX or MIN, it might be impulse noise, so we
increase the window size and try again.

• If it is not, we go to Level B and test to see if the current pixel is


impulse noise.
• If it is, we output the median value, if not, we output the current
value.
• This will tend to preserve edges.
Adaptive Median Filter: How it works
Level A: A1= zmedian – zmin Determine
A2= zmedian – zmax whether zmedian
If A1 > 0 and A2 < 0, goto level B is an impulse or not

Else  Window is not big enough


increase window size
If window size <= Smax repeat level A
Level B: Else return zxy
Determine
 zmedian is not an impulse whether zxy
is an impulse or not
B1= zxy – zmin
B2= zxy – zmax
If B1 > 0 and B2 < 0,  zxy is not an impulse
return zxy  to preserve original details
Adaptive Median Filter: Example

Image corrupted Image obtained Image obtained


by salt-and-pepper using a 7x7 using an adaptive
noise with median filter median filter with
pa=pb= 0.25 Smax = 7

More small details are preserved

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.

Das könnte Ihnen auch gefallen