Image Filtering Advanced Image Filtering Advanced Image filtering with GDI and DX HW accelerations.
Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.
-
Upload
roger-marshall -
Category
Documents
-
view
213 -
download
0
Transcript of Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.
Filtering
Course web page:vision.cis.udel.edu/cv
March 5, 2003 Lecture 9
Announcements
• Read Forsyth & Ponce, Chapter 8-8.3.1, 9.2-9.2.1 for Friday
• Homework 2 will be assigned on Friday and due Monday, March 17
Outline
• Systems, filtering• Linear shift invariance =
convolution• Discrete vs. continuous
convolution• Low-pass filters• Image pyramids
Imaging Systems
• An imaging system describes a functional transformation f of an image due to…– Physics: A real-world phenomenon such as
blurring from defocus or fish-eye lens distortion– Filtering: A transformation we apply in order
to• Undo or mitigate the bad effects of a physical system
(e.g., deblur, undistort, etc.)• Emphasize or highlight particular image properties
(e.g., color similarity, edges, etc.)I I’
f
Linear Shift Invariance
• Possible properties of f– Superposition: f(I1 + I2) = f(I1) + f(I2)
– Scaling: f(®I) = ®f(I)– Shift invariance:
f(Shift(I, k)) = Shift (f(I), k)A system with these properties is performing convolution
What’s Not a Convolution?
• Nonlinear systems– E.g., radial distortion of fish-eye lens
is not LSI because geometric transformation depends on pixel location
f
courtesy of M. Fiala
Impulse Response
• One way to look at what a convolution is doing is to measure its effect on a ± function– Reasonable ± approximation is a black image
containing a single bright dot of light at the origin
• The output is f’s impulse response (aka a point-spread function)
• Convolving an image consists of measuring f’s response to the brightness (a different impulse) at every image location
Continuous Convolution
• Definition:
• Sifting property: If I is the delta function ±, then the integral is 0 everywhere but at x = 0, y = 0, and I’(u, v) = f(u, v) (because ± integrates to 1). Different values of u, v thus map out the point spread function
• An arbitrary I can be represented as an infinite collection of shifted, scaled impulses
Convolution Notes
• Notation: I’ = f ¤ I (book uses ¤¤ for 2-D convolution)
• Note the assumption that both the impulse function and the images are continuous and defined everywhere
• Properties– Commutative– Associative
Discrete Convolution
• Sum instead of integral: I’ = K ¤ I is defined by:
I’(u, v) = §x, y K(u ¡ x, v ¡ y) I(x, y) where the kernel K approximates the impulse function f by
sampling from it where it is non-zero – Think of the last part of HW 1—e.g., if f is a Gaussian, the matrix
of Z-values would be K• Convolution: Correlation with kernel rotated 180
– This distinction goes away for isotropic kernels• Some ways to interpret what the kernel is doing
– As a template being matched by correlation (non-normalized)– As simply a set of weights on the corresponding image pixels
111-121-1-11
Dealing with Image Edges
• Only convolve with interior– Shrinks image
• Zero-padding– Results in spurious gradients
• Border replication• Symmetric: Reflect image at
border b so that I(b + i) = I(b ¡ i)– Results in spurious 2nd-derivatives
3
2
1
2
2
1
3
2
32
21
22
32
1-2-1
24-1
111
Filtering Example 1:
1 -1 -1
1 2 -1
1 1 12 2 2 3
2 1 3 3
2 2 1 2
1 3 2 2
Rotate
1-1-1
12-1
111
(using zero-padding)
Step 1
3
2
1
2
2
1
3
2
32
21
22
32 5
3
2
1
2
2
1
3
2
32
21
22
32
1-2-1
24-1
111
1-1-1
12-1
111
Step 2
3
2
1
2
2
1
3
2
32
21
22
32 45
3
2
1
2
2
1
3
2
32
21
22
32
3-1-2
24-2
111
1-1-1
12-1
111
Step 3
3
2
1
2
2
1
3
2
32
21
22
32 4 45
3
2
1
2
2
1
3
2
32
21
22
32
3-3-1
34-2
111
1-1-1
12-1
111
Step 4
3
2
1
2
2
1
3
2
32
21
22
32 4 4 -25
3
2
1
2
2
1
3
2
32
21
22
32
1-3-3
16-2
111
1-1-1
12-1
111
Step 5
3
2
1
2
2
1
3
2
32
21
22
32 4 4
9
-25
3
2
1
2
2
1
3
2
32
21
22
32
2-2-1
14-1
221
1-1-1
12-1
111
Step 6
3
2
1
2
2
1
3
2
32
21
22
32
6
4 4
9
-25
3
2
1
2
2
1
3
2
32
21
22
32
1-2-2
32-2
222
1-1-1
12-1
111
and so on…
Final Result
2 2 2 3
2 1 3 3
2 2 1 2
1 3 2 2 12
7
6
4
8
6
14
4
59
59
511
-25
I’I
1-1-1
12-1
111
Why is I’ large in some places and small in others?
Smoothing (Low-Pass) Filters
• Problem: How to suppress noise, aliasing?– If object reflectance changes slowly and noise
at each pixel is independent, then we want to replace each pixel with something like the average of neighbors
• Disadvantage: Sharp (high-frequency) features lost
• Types– Mean filter (box)– Median (nonlinear)– Gaussian
111
111
111
3 x 3 box filter
Example: Gaussian Noise
from Forsyth & Ponce
Box Filter: Smoothing
7 x 7 kernelOriginal image
Filtering in Matlab
• imfilter(I, K)filters image I with kernel K– Default filtering is correlation (no kernel
rotation)– Can set options on border handling
• corr2, conv2 are the generic versions• Kernel creation
– Custom (like you did in the last part of HW 1)
– fspecial function