0% found this document useful (0 votes)
33 views18 pages

DIP Module 2-4 Spatial Filtering

The document discusses spatial domain filtering in digital image processing, focusing on smoothing filters used for noise reduction and blurring. It explains the mathematical implementation of these filters, including linear and nonlinear types like median filters, and highlights their effectiveness in preserving image edges. Additionally, it addresses challenges faced at image edges during filtering and various techniques to handle missing pixels.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views18 pages

DIP Module 2-4 Spatial Filtering

The document discusses spatial domain filtering in digital image processing, focusing on smoothing filters used for noise reduction and blurring. It explains the mathematical implementation of these filters, including linear and nonlinear types like median filters, and highlights their effectiveness in preserving image edges. Additionally, it addresses challenges faced at image edges during filtering and various techniques to handle missing pixels.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

DIGITAL IMAGE PROCESSING

(Course Code: CSE 4007)

Module-2:Lecture-4
SPATIAL DOMAIN FILTERING
2D- CORRELATION & CONVOLUTION
Transfer functions of
ideal 1-D filters in
the frequency
domain (a) Lowpass
filter. (b) Highpass
filter. (c) Bandreject
filter. (d) Bandpass
filter. (As before, we
show only positive
frequencies for
simplicity.)

2
Spatial Domain Filtering 2
Basic Spatial Filters

Summary of the four principal spatial filter types expressed in terms of lowpass filters. The
centers of the unit impulse and the filter kernels coincide.

3
Spatial Domain Filtering 3
SMOOTHING SPATIAL FILTERS

One of the simplest spatial filtering operations we can perform is a smoothing operation.
Smoothing filters are used for blurring and for noise reduction
Blurring is used in removal of small details and bridging of small gaps in lines or curves
Smoothing spatial filters include linear filters and nonlinear filters.
Simply average all of the pixels in a neighbourhood around a central value

4
Spatial Domain Filtering 4
SMOOTHING SPATIAL FILTERS-MATHEMATICAL NOTATION

The general implementation for filtering an M N image


with a weighted averaging filter of size m n is given
a b

  w(s, t ) f ( x  s, y  t )
g ( x, y )  s  a t  b a b

  w( s, t )
s  a t  b

where m 2a  1, n 2b  1.

5
Spatial Domain Filtering 5
SMOOTHING SPATIAL FILTERS-MATHEMATICAL NOTATION

Origin x
104 100 108 1
/9 1
/9 1
/9

* /9 /9 /9
1 1 1
99 106 98

95 90 85 1
/9 1
/9 1
/9
Original Image Filter
Simple 3*3
1
/9 100
104 1
/9 108
/9 106
1 1
1
/9
/9 198
/9
3*3 Smoothing Pixels
The above is
99
Neighbourhood /9 190
1
95 /9 185
/9 Filter repeated for every
e = 1/9*106 + pixel in the original
1
/9*104 + 1/9*100 + 1/9*108 + image to generate
1
/9*99 + 1/9*98 + the smoothed
y Image f (x, y) image.
1
/9*95 + 1/9*90 + 1/9*85
= 98.3333

6
Spatial Domain Filtering 6
SMOOTHING SPATIAL FILTERS

The image at the top left is an original image


of size 500*500 pixels
The subsequent images show the image after
filtering with an averaging filter of increasing
sizes 3, 5, 9, 15 and 35
Notice how detail begins to disappear

7
Spatial Domain Filtering 7
SMOOTHING SPATIAL FILTERS

By smoothing the original image we get rid of lots of


the finer detail which leaves only the gross features for
thresholding

Original Image Smoothed Image Thresholded Image

8
Spatial Domain Filtering 8
SMOOTHING SPATIAL FILTERS

— Nonlinear

— Based on ordering (ranking) the pixels contained in the filter mask


`
— Replacing the value of the center pixel with the value determined by the ranking result

E.g., median filter, max filter, min filter

9
Spatial Domain Filtering 9
MEDIAN FILTER
– The median filter is non linear:
median{x  y} median{x}  median{ y}
– It works well for impulse noise (e.g. salt and pepper).
– It requires sorting of the image values.
– It preserves the edges better than an average filter in the
`
case of impulse noise.
– It is robust to impulse noise at 50%.

10
Spatial Domain Filtering 10
AVERAGE VS MEDIAN FILTERS

Filtering is often used to remove noise from images


Sometimes a median filter works better than an
averaging filter

11
Spatial Domain Filtering 11
STRANGE THINGS HAPPENS AT THE EDGES…

At the edges of an image we are missing


pixels to form a neighbourhood
Origin x
e e

e e e
y
Image f (x, y)
12
Spatial Domain Filtering 12
STRANGE THINGS HAPPENS AT THE EDGES…

There are a few approaches to dealing with missing edge pixels:


 Omit missing pixels
• Only works with some filters
• Can add extra code and slow down processing
 Pad the image
`
• Typically with either all white or all black pixels
 Replicate border pixels
 Truncate the image
 Allow pixels wrap around the image
• Can cause some strange image artefacts

13
Spatial Domain Filtering 13
`

14
Spatial Domain Filtering 14
Wrap Padding

15
Spatial Domain Filtering 15
Wrap Padding

16
Spatial Domain Filtering 16
Problems on Smoothing Filters

Filter the given 4 x 4 gray level image with

`
a. 3 x 3 mean filter using zero padding
b. 3 x 3 weighted mean filter using wrap-around technique for border handling.
c. 5x5 median filter processing using replication for handling border pixels.

17
Spatial Domain Filtering 17
Pixel Relationships 18

You might also like