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
212 -
download
0
Transcript of Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.
![Page 1: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/1.jpg)
Filtering
Course web page:vision.cis.udel.edu/cv
March 5, 2003 Lecture 9
![Page 2: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/2.jpg)
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
![Page 3: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/3.jpg)
Outline
• Systems, filtering• Linear shift invariance =
convolution• Discrete vs. continuous
convolution• Low-pass filters• Image pyramids
![Page 4: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/4.jpg)
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
![Page 5: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/5.jpg)
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
![Page 6: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/6.jpg)
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
![Page 7: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/7.jpg)
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
![Page 8: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/8.jpg)
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
![Page 9: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/9.jpg)
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
![Page 10: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/10.jpg)
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
![Page 11: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/11.jpg)
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
![Page 12: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/12.jpg)
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)
![Page 13: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/13.jpg)
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
![Page 14: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/14.jpg)
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
![Page 15: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/15.jpg)
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
![Page 16: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/16.jpg)
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
![Page 17: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/17.jpg)
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
![Page 18: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/18.jpg)
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
![Page 19: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/19.jpg)
and so on…
![Page 20: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/20.jpg)
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?
![Page 21: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/21.jpg)
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
![Page 22: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/22.jpg)
Example: Gaussian Noise
from Forsyth & Ponce
![Page 23: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/23.jpg)
Box Filter: Smoothing
7 x 7 kernelOriginal image
![Page 24: Filtering Course web page: vision.cis.udel.edu/cv March 5, 2003 Lecture 9.](https://reader030.fdocuments.in/reader030/viewer/2022032802/56649e025503460f94aed7ef/html5/thumbnails/24.jpg)
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