Median Filter If the objective is to achieve noise reduction
rather than blurring, an alternative approach is to use median
filters. That is, the gray level of each pixel is replaced by the
median of the gray levels in a neighbourhood of that pixel, instead
of by the average.
Slide 2
This method is particularly effective when the noise pattern
consists of strong, spike-like components and the characteristic to
be preserved is edge sharpness. The median m of a set of values is
such that half the values in the set are less than m and half are
greater than m. In order to perform median filtering in a
neighbourhood of a pixel, we first sort the values of the pixel and
its neighbours, determine the median, and assign this value to the
pixel.
Slide 3
For example, in a 3 X 3 neighbourhood the median is the 5th
largest value, in a 5 x 5 neighbourhood the 13th largest value, and
so on. When several values in a neighbourhood are the same, all
equal values have to be grouped. For example, suppose that a 3 X 3
neighbourhood has values (10, 20, 20, 20, 15, 20, 20, 25,100).
These values are sorted as (10, 15, 20, 20, 20, 20, 20, 25, 100),
which results in a median of 20.
Slide 4
Thus the principal function of median filtering is to force
points with distinct intensities to be more like their neighbours,
actually eliminating intensity spikes that appear isolated in the
area of the filter mask.
Slide 5
(b)(c)(a) Fig.7.28 Noise suppression. (a) Original image
corrupted by 5% impulse noise (b) Result of 3 x 3 mean filtering
(c) Result of 3 x 3 median filtering.
Slide 6
64 255 64 255 64 25564 255 64 25564128 64 128 64 255128
Fig.7.29 A 3 x 3 neighbourhood within a portion of the image in
Fig.7.28(a)
Slide 7
The new value obtained for this pixel using a 3 x 3 mean filter
is (64+64+64+64+255+255+64+64+255)/9=128 So mean filtering has not
removed the noise completely. To apply a median filter, we place
the grey levels from the neighbourhood in a list,
{64,64,64,64,255,255,64,64,255}, and sort the list into ascending
order {64,64,64,64,64,64,255,255,255}.
Slide 8
The median from this set of values is 64. The noisy values have
migrated to the end of the list. Clearly, median filtering can
eliminate the impulse noise only if the noisy pixels occupy less
than half the area of the neighbourhood.
Slide 9
Edge detection One of the major applications for convolution is
in edge detection. Edges can be defined loosely as locations in an
image where there is a sudden variation in the grey level of
pixels. The contours of solid objects, surface markings, shadows,
etc. all generate intensity or colour edges.
Slide 10
The most common method in edge detection is based on the
estimation of grey level gradient at a pixel. The gradient is used
frequently in industrial application, either to aid humans in the
detection of defects or, as a preprocessing step in automated
inspection.
Slide 11
Fig.7.30. (a) A 3 x 3 region of an image (the zs are grey level
values); (b) Prewitt masks; (c) Sobel masks used to compute the
gradient at point labelled z 5. z1z1 z2z2 z3z3 z4z4 z5z5 z6z6 z7z7
z8z8 z9z9 (a)
Slide 12
000 111 01 01 01 (b) Prewitt operator
Slide 13
-2 000 121 01 -202 01 (c) Sobel operator
Slide 14
For Prewitte operator, the gradient magnitude g is given by g
|(z 7 + z 8 + z 9 ) - (z 1 + z 2 + z 3 )| + |(z 3 + z 6 + z 9 ) -
(z 1 + z 4 + z 7 )| For Sobel operator, g is given by g |(z 7 + 2z
8 + z 9 ) - (z 1 + 2z 2 + z 3 )| + |(z 3 + 2z 6 + z 9 ) - (z 1 + 2z
4 + z 7 )|
Slide 15
Fig.7.31. Optical image of contact lens (note defects on the
boundary at 4 and 5 oclock). (a) original image (b) result of Sobel
gradient (a)(b)