Professional Documents
Culture Documents
Lecture 7
Lecture 7
of
19
of
19
Contents
In this lecture we will look at spatial filtering
techniques:
– Neighbourhood operations
– What is spatial filtering?
– Smoothing operations
– What happens at the edges?
– Correlation and convolution
Image Enhancement
(Spatial Filtering 1)
3 4
of
19
Neighbourhood Operations of
19
Simple Neighbourhood Operations
Neighbourhood operations simply operate Some simple neighbourhood operations
on a larger neighbourhood of pixels than include:
point operations Origin x – Min: Set the pixel value to the minimum in
Neighbourhoods are the neighbourhood
mostly a rectangle – Max: Set the pixel value to the maximum in
around a central pixel the neighbourhood
(x, y) – Median: The median value of a set of
Any size rectangle Neighbourhood
numbers is the midpoint value in that set (e.g.
and any shape filter from the set [1, 7, 15, 18, 24] 15 is the
are possible median). Sometimes the median works better
y Image f (x, y)
than the average
1
5 Simple Neighbourhood Operations 6
of of The Spatial Filtering Process
19 Example 19
Origin x
a b c r s t
Original Image x Enhanced Image x
123 127 128 119 115 130
d
g
e
h
f
i
* u
x
v
y
w
z
140 145 148 153 167 172 Original Image Filter
Simple 3*3 Pixels
e 3*3 Filter
Neighbourhood
133 154 183 192 194 191
eprocessed = v*e +
194 199 207 210 198 195 r*a + s*b + t*c +
u*d + w*f +
164 170 175 162 173 151 y Image f (x, y) x*g + y*h + z*i
y y
The above is repeated for every pixel in the
original image to generate the filtered image
7 8
of
19
Spatial Filtering: Equation Form of
19
Smoothing Spatial Filters
a b One of the simplest spatial filtering
w(s, t ) f ( x s, y t )
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
2
9 10
of
19
Smoothing Spatial Filtering of
19
Smoothing Spatial Filtering
Origin x Origin x
104 100 108 1/ 1/ 1/ 104 100 108 1/ 1/ 1/
9 9 9 9 9 9
99 106 98
95 90 85
* 1/
1/
9
1/
1/
9
1/
1/
9 99 106 98
95 90 85
* 1/
1/
9
1/
1/
9
1/
1/
9
9 9 9 9 9 9
1/ 100
104
9
1/ 108
9
1/
9
Original Image Filter 1/ 100
104
9
1/ 108
9
1/
9
Original Image Filter
Simple 3*3 199
/9 1106
/9 198
/9
3*3 Smoothing Pixels Simple 3*3 199
/9 1106
/9 198
/9
3*3 Smoothing Pixels
Neighbourhood 195
/9 190
/9 185
/9
Filter Neighbourhood 195
/9 190
/9 185
/9
Filter
e = 1/9*106 + e = 1/9*___ +
1/ *104 + 1/ *100 + 1/ *108 + 1/ *___ + 1/ *___ + 1/ *___ +
9 9 9 9 9 9
1/ *99 + 1/ *98 + 1/ ___ + 1/ *___ +
9 9 9 9
y Image f (x, y) 1/ *95 + 1/ *90 + 1/ *85 y Image f (x, y) 1/ *___ + 1/ *___ + 1/ *___
9 9 9 9 9 9
= 98.3333 = _____
The above is repeated for every pixel in the The above is repeated for every pixel in the
original image to generate the smoothed image original image to generate the smoothed image
11 12
of
19
Image Smoothing Example of
19
Weighted Smoothing Filters
The image at the top left More effective smoothing filters can be
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
3
13 14 Averaging Filter Vs. Median Filter
of Another Smoothing Example of
19 19 Example
By smoothing the original image we get rid
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
of lots of the finer detail which leaves only
the gross features for thresholding
4
17 Strange Things Happen At The Edges! 18
of of Correlation & Convolution
19 (cont…) 19
19 20
of
19
of
19
Summary
In this lecture we have looked at the idea of
spatial filtering and in particular:
– Neighbourhood operations
– The filtering process
– Smoothing filters
– Dealing with problems at image edges when
using filtering
– Correlation and convolution
Next time we will looking at sharpening
filters and more on filtering and image
enhancement