Title: 3-D Computer Vision CSc 83020
13-D Computer VisionCSc 83020
- Image Processing I/Filtering
2Image Processing I/Filtering
- Convolution (1-D)
- Linear Shift Invariant Systems
- Convolution (2-D)
- Application Noise
- Filtering Averaging, Smoothing, Median..
3Convolution (Important!)
h
f
g
Used for Derivatives, Edges, Matching,
4Convolution
h
f
g
5Convolution
f(?)
x
?
h(?)
6Convolution
f(?)
x
?
h(?)
h(-?)
7Convolution
f(?)
x
?
h(?)
h(-?)
h(x-?)
?
x
8Convolution
f(?)
h(x-?)
x
?
f(?) h(x-?)
x
?
g(x) area under curve
9Convolution
f(?)
h(x-?)
x
?
f(?) h(x-?)
?
x
g(x) area under curve
Calculate g(x) for all x!!
10Convolution
g(x)
x
f(x)
h(x)
Calculate g(x) for all x!! gt g(x) 1-D function
11Example
a(?)
b(?)
1
1
?
?
1
-1
1
-1
c a b
?
12Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
13Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
xlt-2
14Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
x-2
15Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
-2ltxlt-1
16Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
-2ltxlt-1
17Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
x-1
18Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
-1ltxlt0
19Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
x0
20Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
0ltxlt1
21Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
x1
22Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
1ltxlt2
23Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
x2
24Example
a(?)
b(-?)
1
1
?
?
1
-1
1
-1
a(?)
1
b(x-?)
?
1
-1
x
xgt2
25Example
a(?)
b(?)
1
1
?
?
1
-1
1
-1
c a b
c(x)
1
x
1
-1
-2
2
26Properties of Convolution
- Commutativity b a a b.
- Associativity (a b) c a (b c)
- Cascaded system
g
f
h1
h2
g
f
h1h2
Equivalent Systems
g
f
h2h1
27Convolution Discrete
f(?)
m
?
m1
m2
h(?)
n2
n1
Discrete samples of continuous signal. Sampling
at regular intervals. Example Scanline
28Convolution Discrete
f(?)
m
m-n1
m-n2
?
m1
m2
h(?)
n2
n1
29One Scan Line 1-D discrete signal
f(?), m10, m2450.
0
450
30One Scan Line 1-D discrete signal
f(?), m10, m2450.
1/9
0
450
fh ?
4
-4
h(?), n1-4, n24.
31One Scan Line 1-D discrete signal
f(?)
1/9
h(m- ?)
m
m4
m-4
0
450
m
fh ?
32One Scan Line 1-D discrete signal
f(?)
1/9
h(m- ?)
m
m4
m-4
0
450
m
fh ?
33One Scan Line 1-D discrete signal
f(?), m10, m2450.
0
450
h filter or mask. fh filtered version of
f. In this case h spatially averages f in a
neighborhood of 9 samples.
34Recap
- 1-D Convolution
- Continuous vs. Discrete.
- Finite vs. Infinite signals (spatial domain).
- Filtering.
35Linear Shift Invariant Systems
f(x)
g(x)
Linearity
f1(x)
g1(x)
f2(x)
g2(x)
af1(x)bf2(x)
ag1(x)bg2(x)
36Linear Shift Invariant Systems
f(x)
g(x)
Shift Invariance
f(x-a)
g(x-a)
g(x)
f(x)
x
x
g(x)
f(x-a)
x
x
a
a
37Properties of Convolution
- Commutativity b a a b.
- Associativity (a b) c a (b c)
- Cascaded system
g
f
h1
h2
g
f
h1h2
Equivalent Systems
g
f
h2h1
38Convolution
Used for Derivatives, Edges, Matching,
Convolution LINEAR SHIFT INVARIANT
f(x)
g(x)
h(x)
Also, any LSIS is doing a CONVOLUTION!
39Properties of Convolution
- Commutativity b a a b.
- Associativity (a b) c a (b c)
- Cascaded system
g
f
h1
h2
g
f
h1h2
Equivalent Systems
g
f
h2h1
40Example of LSIS
g
f
Defocused image g Processed version of Focused
image f. Ideal Lens
f(x)
g(x)
LSIS
Linearity Brightness Variations. Shift
Invariance Scene Movement. Note Not valid for
lenses with non-linear distortions
(aberrations). Study of LSIS leads to useful
algorithms for processing images!
41System as a black box
g
f
h
Can we find h? What f will give us gh?
1/(2e)
d(x)
d(x)
d(x)
1/(2e)
1/(2e)
Decrease e
Decrease e
x
x
x
2e
2e
2e
42System as a black box
d(x)
Unit Impulse Function
1/(2e)
x
1
-1
2e
Impulse Response
f(x)d(x)
h(x)
IMPULSE RESPONSE
43Impulse Response
f(x)d(x)
h(x)
IMPULSE RESPONSE
44Image Formation
Scene
Image
Optical System
Point Source d(x)
Point Spread Function h(x)
Optical System
In an ideal system h(x)d(x) Optical Systems are
never ideal!
Human Eye Point Spread Function.
452-D Convolution
g(x,y) Output Image
h(x,y) Filter
f(x,y) Input Image
46Discrete Convolution
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
y
(0,0)
g (larger than f)
x
h
f
47Discrete Convolution
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
1 1 1 1 1
1 2 2 2 1
1 2 3 2 1
1 2 2 2 1
1 1 1 1 1
f
h
48Discrete Convolution 2D flip
1 1 1 1 1
4 3 2 2 1
4 5 3 2 1
4 5 5 3 1
4 4 4 4 1
1 4 4 4 4
1 3 5 5 4
1 3 3 5 4
1 3 3 3 4
1 1 1 1 1
49Discrete Convolution
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
g
f
h
50Discrete Convolution
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
51Discrete Convolution
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
52Discrete Convolution
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
53Discrete Convolution
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
54Discrete Convolution
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
55Discrete Convolution
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
56Discrete Convolution
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
57Discrete Convolution
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
58Discrete Convolution
1 2 3 4 5 4 3
2 1 2 6 10 14 16 14
10 6 2 3 10 20 28 32
28 20 10 3 4 14 28 42
48 42 28 14 4 5 16 32
48 57 48 32 16 5 4 14
28 42 48 42 28 14 4 3
10 20 28 32 28 20 10 3
2 6 10 14 16 14 10 6
2 1 2 3 4 5 4 3
2 1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
f
g
h
g is larger than f. Finite borders!
59Discrete Convolution
h
g
f
60Discrete Convolution
Commutativity
h
g
f
61Gaussian Noise
62Linear Filtering
m size of filter (odd number) m/2 integer
(i.e. if m5, m/22)
63Linear Filtering
m3
64Mean Filtering - Averaging
m3
65Gaussian Filtering
Separable Kernel
66Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
I
gr
Ir
67Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
68Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
69Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
70Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
71Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
72Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
73Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
1 1 1 1 1 1 2 2
2 1 1 2 3 2 1 1
2 2 2 1 1 1 1 1
1
y y y y y
I
gr
Ir
74Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
y y y y y
Ir
gc
IG
75Separable convolution
y y y y y
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
76Separable convolution
y y y y y
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
77Separable convolution
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x x
x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x x
x x x x x x x x
y y y y y
Ir
gc
IG
78Separable convolution
Two 1-D convolutions are more efficient than one
2-D convolution!
79Gaussian Filtering
80Constructing a Gaussian Filter
1-D Gaussian Mask g w width of mask (in
pixels) s continuous Gaussian kernel Relation
between w and s
81Size of the mask
82Noise Median Filter
Cannot implement with a convolution mask.
83Noise Median Filter
Cannot implement with a convolution mask.