ImageProcessing5 SpatialFiltering1
ImageProcessing5 SpatialFiltering1
IMAGE ENHANCEMENT
(SPATIAL FILTERING 1)
Contents
y Image f (x, y)
Simple Neighbourhood Operations
y y
The Spatial Filtering Process
Origin x
a b c r s t
d
g
e
h
f
i
* u
x
v
y
w
z
Original Image Filter
Simple 3*3 Pixels
e 3*3 Filter
Neighbourhood
eprocessed = v*e +
r*a + s*b + t*c +
u*d + w*f +
y Image f (x, y) x*g + y*h + z*i
a b
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
g ( x, y ) w(s, t ) f ( x s, y t )
s at b
* /9 /9 /9
1 1 1
99 106 98
95 90 85 1
/9 1
/9 1
/9
1
/9 100
104 1
/9 108
1
/9
Original Image Filter
Simple 3*3 /9 106
1
99 1
/9 198
/9
3*3 Smoothing Pixels
Neighbourhood /9 190
1
95 /9 185
/9 Filter
e = 1/9*106 +
1
/9*104 + 1/9*100 + 1/9*108 +
1
/9*99 + 1/9*98 +
y Image f (x, y) 1
/9*95 + 1/9*90 + 1/9*85
= 98.3333
The above is repeated for every pixel in the
original image to generate the smoothed image
Image Smoothing Example
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
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Often referred to as a
weighted averaging 2
/16 4
/16 /16
2
1
/16 2
/16 /16
1
Weighted
averaging filter
Another Smoothing Example
By smoothing the original image we get rid of lots
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
x
123 127 128 119 115 130
y
Strange Things Happen At The Edges!
e e e
y Image f (x, y)
Strange Things Happen At The Edges!
(cont…)
x
123 127 128 119 115 130
y
Strange Things Happen At The Edges!
(cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
Filtered Image:
Zero Padding
Filtered Image:
Wrap Around Edge Pixels
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
(cont…)
Strange Things Happen At The Edges!
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
(cont…)
Strange Things Happen At The Edges!
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
(cont…)
Strange Things Happen At The Edges!
Correlation & Convolution
The filtering we have been talking about so far is
referred to as correlation with the filter itself
referred to as the correlation kernel
Convolution is a similar operation, with just one
subtle difference
a b c r s t
d e e u v w eprocessed = v*e +
f g h x y z
Original
Image
* Filter
z*a + y*b + x*c +
w*d + u*e +
Pixels t*f + s*g + r*h