Professional Documents
Culture Documents
Spatial Filtering
Contents
Spatial domain
Intensity transformation
Basic functions
Histogram processing
Spatial filtering
Spatial
The image plane or direct manipulation of pixels
g(x,y) = T[f(x,y)]
Spatial filtering
Simple 3*3
Original Filter (w)
e 3*3 Filter
Neighbourhood Image
Pixels
eprocessed = n*e +
j*a + k*b + l*c +
y Image f (x, y) m*d + o*f +
p*g + q*h + r*i
The above is repeated for every pixel in the original image to generate the filtered image
Spatial filtering
Gaussian
Spatial filtering
Correlation
Convolution
Spatial filtering
Image convolution
Spatial filtering
Vector representation
R = wTz
Correlation filtering
we have been talking about so far
Convolution filtering
similar operation, with just one subtle difference
a b c r s t eprocessed = v*e +
z*a + y*b + x*c +
d
f
e
g
e
h
* u
x
v
y
w
z
w*d + u*e +
t*f + s*g + r*h
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0
0 0
0 0
0 90
90 0
0 90
90 90
90 90
90 0
0 0
0
0
0 0
0 0
0 90
90 90
90 90
90 90
90 90
90 0
0 0
0
0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0
0
0 0
0 90
90 0
0 0
0 0
0 0
0 0
0 0
0 0
0
0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0
a b
g ( x, y ) h ( s, t ) f ( x s, y t )
s a t b
Dr. Asif Khan, GIK Institute, Spring 2017 Credit: S. Seitz
Advanced Image Processing
Spatial Filtering
1 1 1
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 10
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 10 20
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 10 20 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
?
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 10 20 30 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
?
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
50
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
f [.,.] g[.,.] h[ , ] 1 1 1
1 1 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0
0 20 40 60 60 60 40 20
0 0 0 90 90 90 90 90 0 0
0 30 60 90 90 90 60 30
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 90 90 90 90 0 0
0 30 50 80 80 90 60 30
0 0 0 0 0 0 0 0 0 0
0 20 30 50 50 60 40 20
0 0 90 0 0 0 0 0 0 0
10 20 30 30 30 30 20 10
0 0 0 0 0 0 0 0 0 0
10 10 10 0 0 0 0 0
f
f ( x 1) f ( x)
x
f(x)
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
0 -1 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
f
f ( x 1) f ( x)
x
f(x)
f(x)
f(x)
2 f
f ( x 1) f ( x 1) 2 f ( x )
x
2
Isolated point
Step
f(x)
Thin Line
Nonzero along
the entire ramp
f(x)
Fine Edges
Stronger response
Dr. Asif Khan, GIK Institute, Spring 2017
Advanced Image Processing
Spatial Filtering
2 f [ f ( x 1, y ) f ( x 1, y )
f f
2 2
2 f 2 f ( x, y 1) f ( x, y 1)]
x y
2
4 f ( x, y )
f2
f ( x 1, y ) f ( x 1, y ) 2 f ( x, y )
x
2
0 1 0
2 f 1 -4 1
f ( x, y 1) f ( x, y 1) 2 f ( x, y )
y
2
0 1 0
Dr. Asif Khan, GIK Institute, Spring 2017
Advanced Image Processing
Spatial Filtering
g ( x, y ) f ( x, y ) 2 f
g ( x, y ) f ( x, y ) f 2
f ( x, y ) [ f ( x 1, y ) f ( x 1, y )
f ( x, y 1) f ( x, y 1)
4 f ( x, y )]
5 f ( x, y ) f ( x 1, y ) f ( x 1, y )
f ( x, y 1) f ( x, y 1)
Dr. Asif Khan, GIK Institute, Spring 2017
Advanced Image Processing
Spatial Filtering
0 -1 0
-1 5 -1
0 -1 0
Highboost filtering
If A > 1
Highboost filtering
If A > 1
Highboost filtering
Highboost filtering
f
Gx x
f f
Gy
y
the direction of the greatest rate of change of f at location (x, y)
f
f ( x ) f ( x 1) Backward Distance
x
f
f ( x 1) f ( x 1) Central Distance
x
mag( f ) 2
Gx G y
1
2 2
Gx G y
Gx ( z8 z5 ) and G y ( z6 z5 ) Forward Distance
mag( f ) z3 z6 z9 z1 z4 z7
z7 z8 z9 z1 z2 z3
-1 0 1 z1 z2 z3 -1 -1 -1
-1 0 1 z4 z5 z6 0 0 0
-1 0 1 z7 z8 z9 1 1 1
Gx f ( x 1, y 1) f ( x 1, y ) f ( x 1, y 1)
f ( x 1, y 1) f ( x 1, y ) f ( x 1, y 1)
G y f ( x 1, y 1) f ( x, y 1) f ( x 1, y 1)
f ( x 1, y 1) f ( x, y 1) f ( x 1, y 1)
Dr. Asif Khan, GIK Institute, Spring 2017
Advanced Image Processing
Spatial Filtering
-1 0 1 -1 -2 -1
-2 0 2 0 0 0
-1 0 1 1 2 1
1 0 -1
2 0 -2
1 0 -1
1 2 1
0 0 0
-1 -2 -1
Acknowledgement