07 - Spatial Filtering
07 - Spatial Filtering
Spatial filtering
Stefano Ferrari
Filtering
Spatial filtering
Linear filtering
I Correlation
a
X b
X
g (x, y ) = w (x, y )?f (x, y ) = w (s, t) f (x +s, y +t)
s=−a t=−b
I Convolution
a
X b
X
g (x, y ) = w (x, y )∗f (x, y ) = w (s, t) f (x −s, y −t)
s=−a t=−b
I Vectorial representation
mn
X
R = w1 z1 + · · · + wmn zmn = wk zk = w T z
k=1
Correlation
f w
0 0 0 1 0 0 0 0 1 2 3 2 8
↓
f 0 0 0 1 0 0 0 0
w 1 2 3 2 8
↑ starting position alignment
zero padding
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
Correlation (2)
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0 8
Correlation (3)
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0 8
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0 8 2
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0 8 2 3
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0 8 2 3 2
Correlation (4)
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0 8 2 3 2 1
...
f 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
w 1 2 3 2 8
w ?f 0 0 0 8 2 3 2 1 0 0 0 0
w ?f 0 0 0 8 2 3 2 1 0 0 0 0
Cropping 0 8 2 3 2 1 0 0
f 0 0 0 1 0 0 0 0
Convolution
f w rotated 180◦
0 0 0 1 0 0 0 0 8 2 3 2 1
↓
f 0 0 0 1 0 0 0 0
w 8 2 3 2 1
↑ starting position alignment
...
w ∗f 0 0 0 1 2 3 2 8 0 0 0 0
Cropping 0 1 2 3 2 8 0 0
f 0 0 0 1 0 0 0 0
Vectorial representation
mn
X
R = w1 z1 + · · · + wmn zmn = wk zk = w T z
k=1
Filter specification
Smoothing filters
f g =f ∗h m=g >θ
Non-linear filters
a b c
DIP 3e, Sects. 3.4, 3.5 DIP 4e, Sects. 3.4, 3.5
I pp. 144–156 I pp. 177–198
GIMP
I Filters
I Blur
I Enhance
I Despeckle
I Generic
I Convolution matrix