convolution and edge detection - cmu graphics...
TRANSCRIPT
![Page 1: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/1.jpg)
Convolution and Edge Detection
15-463: Computational PhotographyAlexei Efros, CMU, Fall 2005Some slides from Steve Seitz
![Page 2: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/2.jpg)
Fourier spectrum
![Page 3: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/3.jpg)
Fun and games with spectra
![Page 4: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/4.jpg)
4
Gaussian filteringA Gaussian kernel gives less weight to pixels further from the center of the window
This kernel is an approximation of a Gaussian function:
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 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
1 2 1
2 4 2
1 2 1
![Page 5: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/5.jpg)
5
Mean vs. Gaussian filtering
![Page 6: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/6.jpg)
ConvolutionRemember cross-correlation:
A convolution operation is a cross-correlation where the filter is flipped both horizontally and vertically before being applied tothe image:
It is written:
Suppose H is a Gaussian or mean kernel. How does convolution differ from cross-correlation?
![Page 7: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/7.jpg)
The Convolution TheoremThe greatest thing since sliced (banana) bread!
• The Fourier transform of the convolution of two functions is the product of their Fourier transforms
• The inverse Fourier transform of the product of two Fourier transforms is the convolution of the two inverse Fourier transforms
• Convolution in spatial domain is equivalent to multiplication in frequency domain!
]F[]F[]F[ hghg =∗
][F][F][F 111 hggh −−− ∗=
![Page 8: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/8.jpg)
Fourier Transform pairs
![Page 9: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/9.jpg)
2D convolution theorem example
*
f(x,y)
h(x,y)
g(x,y)
|F(sx,sy)|
|H(sx,sy)|
|G(sx,sy)|
![Page 10: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/10.jpg)
Edges in images
![Page 11: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/11.jpg)
Image gradientThe gradient of an image:
The gradient points in the direction of most rapid change in intensity
The gradient direction is given by:
• how does this relate to the direction of the edge?The edge strength is given by the gradient magnitude
![Page 12: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/12.jpg)
Effects of noiseConsider a single row or column of the image
• Plotting intensity as a function of position gives a signal
Where is the edge?
How to compute a derivative?
![Page 13: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/13.jpg)
Where is the edge?
Solution: smooth first
Look for peaks in
![Page 14: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/14.jpg)
Derivative theorem of convolution
This saves us one operation:
![Page 15: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/15.jpg)
Laplacian of Gaussian
Consider
Laplacian of Gaussianoperator
Where is the edge? Zero-crossings of bottom graph
![Page 16: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/16.jpg)
2D edge detection filters
is the Laplacian operator:
Laplacian of Gaussian
derivative of GaussianGaussian
![Page 17: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/17.jpg)
MATLAB demo
g = fspecial('gaussian',15,2);imagesc(g)surfl(g)gclown = conv2(clown,g,'same');imagesc(conv2(clown,[-1 1],'same'));imagesc(conv2(gclown,[-1 1],'same'));dx = conv2(g,[-1 1],'same');imagesc(conv2(clown,dx,'same');lg = fspecial('log',15,2);lclown = conv2(clown,lg,'same');imagesc(lclown)imagesc(clown + .2*lclown)
![Page 18: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/18.jpg)
What does blurring take away?
original
![Page 19: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/19.jpg)
What does blurring take away?
smoothed (5x5 Gaussian)
![Page 20: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/20.jpg)
Edge detection by subtraction
smoothed – original
Why doesthis work?
![Page 21: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/21.jpg)
Gaussian - image filter
Laplacian of Gaussian
Gaussian delta function
FFT
![Page 22: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/22.jpg)
What is happening?
![Page 23: Convolution and Edge Detection - CMU Graphics Labgraphics.cs.cmu.edu/courses/15-463/2005_fall/www/Lectures/... · Convolution and Edge Detection 15-463: ... A convolution operation](https://reader033.vdocuments.net/reader033/viewer/2022051523/5a78fd347f8b9a523d8ba52a/html5/thumbnails/23.jpg)
Unsharp Masking
- =
=+ α