Sunteți pe pagina 1din 38

MEDIAN FILTER

MEAN FILTERS
INTRODUCTION
In signal processing, it is often desirable to be able to perform some
kind of noise reduction on an image or signal. The median filter is a
nonlinear digital filtering technique, often used to remove noise. Median
filtering is very widely used in digital image processing because it
preserves edges while removing noise.
















Definitions of the components/Keywords
The median filter is a sliding-window spatial filter.

It replaces the value of the center pixel with the median of the intensity values
in the neighborhood of that pixel.

Median filtering is a nonlinear operation often used in image processing to
reduce "salt and pepper" noise. A median filter is more effective than
convolution when the goal is to simultaneously reduce noise and preserve
edges.


Median filters are particularly effective in the presence of impulse noise,
also called salt and pepper noise because of its appearance as white and
black dots superimposed on an image.

For every pixel, a 3x3 neighborhood with the pixel as center is considered. In
median filtering, the value of the pixel is replaced by the median of the pixel
values in the 3x3 neighborhood.

Step 1:
Noise density 0.01
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.01, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.01
The resulting image after median filtering is done

Step 2:
Noise density 0.02
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.02, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.02
The resulting image after median filtering is done

Step 3:
Noise density 0.05
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.05, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.05
The resulting image after median filtering is done

Step 4:
Noise density 0.07
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.07, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.07
The resulting image after median filtering is done

Step 5:
Noise density 0.09
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.09, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.09
The resulting image after median filtering is done

Step 6:
Noise density 0.1
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.1, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.1
The resulting image after median filtering is done

Step 7:
Noise density 0.15
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.15, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.15
The resulting image after median filtering is done

Step 8:
Noise density 0.2
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.2, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.2
The resulting image after median filtering is done

Step 9:
Noise density 0.22
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.22, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.22
The resulting image after median filtering is done

Step 10:
Noise density 0.3
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.3, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.3
The resulting image after median filtering is done

Step 11:
Noise density 0.4
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.4, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.4
The resulting image after median filtering is done

Step 12:
Noise density 0.5
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.5, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.5
The resulting image after median filtering is done

Step 13:
Noise density 0.6
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.6, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.6
The resulting image after median filtering is done

Step 14:
Noise density 0.7
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.7, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.7
The resulting image after median filtering is done

Step 15:
Noise density 0.8
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.8, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.8
The resulting image after median filtering is done

Step 16:
Noise density 0.9
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 0.9, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 0.9
The resulting image after median filtering is done

Step 17:
Noise density 1
Instruction for the animator Text to be displayed in the working area (DT)
The first fig. should appear and then when
the slider points at 1, the second fig.
should be shown
The text in DT should appear in parallel to
the figures
The image with salt & pepper noise with noise density 1
The resulting image after median filtering is done

Questionnaire

1.What is the value of the yellow box after median
filtering?




Answers: a) 7 b) 1 c) 3 d) 9
Questionnaire
2.





What are the values of yellow boxes after median filtering is
done?

Answers: a) b)






Median filter
{ } ) , (
median
) , (

) , (
t s g y x f
xy
S t s e
=
Max filter
{ } ) , (
max
) , (

) , (
t s g y x f
xy
S t s e
=
Min filter
{ } ) , (
min
) , (

) , (
t s g y x f
xy
S t s e
=
Midpoint filter
{ } { }
|
.
|

\
|
+ =
e e
) , (
min
) , (
max
2
1
) , (

) , ( ) , (
t s g t s g y x f
xy xy
S t s S t s
Reduce dark noise
(pepper noise)
Reduce bright noise
(salt noise)
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2
nd
Edition.
Max and Min Filters: Example
Image
corrupted
by pepper
noise with
prob. = 0.1
Image
corrupted
by salt
noise with
prob. = 0.1
Image
obtained
using a 3x3
max filter
Image
obtained
using a 3x3
min filter
Mean Filters
Arithmetic mean filter or moving average filter (from Chapter 3)

e
=
xy
S t s
t s g
mn
y x f
) , (
) , (
1
) , (

Geometric mean filter


mn
S t s
xy
t s g y x f
1
) , (
) , ( ) , (

|
|
.
|

\
|
=
[
e
mn = size of moving window
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2
nd
Edition.
Geometric Mean Filter: Example
Original
image
Image
corrupted
by AWGN
Image
obtained
using a 3x3
geometric
mean filter
Image
obtained
using a 3x3
arithmetic
mean filter
AWGN: Additive White Gaussian Noise
Harmonic and Contraharmonic Filters
Harmonic mean filter

e
=
xy
S t s
t s g
mn
y x f
) , (
) , (
1
) , (

Contraharmonic mean filter

e
e
+
=
xy
xy
S t s
Q
S t s
Q
t s g
t s g
y x f
) , (
) , (
1
) , (
) , (
) , (

mn = size of moving window


Works well for salt noise
but fails for pepper noise
Q = the filter order
Positive Q is suitable for
eliminating pepper noise.
Negative Q is suitable for
eliminating salt noise.
For Q = 0, the filter reduces to an arithmetic mean filter.
For Q = -1, the filter reduces to a harmonic mean filter.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2
nd
Edition.
Contraharmonic Filters: Example
Image
corrupted
by pepper
noise with
prob. = 0.1
Image
corrupted
by salt
noise with
prob. = 0.1
Image
obtained
using a 3x3
contra-
harmonic
mean filter
With Q = 1.5
Image
obtained
using a 3x3
contra-
harmonic
mean filter
With Q=-1.5
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2
nd
Edition.
Contraharmonic Filters: Incorrect Use Example
Image
corrupted
by pepper
noise with
prob. = 0.1
Image
corrupted
by salt
noise with
prob. = 0.1
Image
obtained
using a 3x3
contra-
harmonic
mean filter
With Q=-1.5
Image
obtained
using a 3x3
contra-
harmonic
mean filter
With Q=1.5

S-ar putea să vă placă și