Week 8
Week 8
“interpolation averaging
X
”
Convolution: Weighted sum over pixels
Filters
Boundary issues
• What about near the edge?
– the filter window falls off the edge of the image
– need to extrapolate
– methods:
• clip filter (black)
• wrap around
• copy edge
• reflect across edge
f f f
g g g
g g g
Objects
Lines
Edges
Pixels
Images
[Slide by Neeraj Kumar]
Edge detection
* =
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Smooth first, then derivative
Sobel filter! Smooth & derivative
Solution: smooth first
- =
σ = 2 σ = 1
Difference of Gaussian (DoG)
- g(σ1)*I - g(σ2)*I = [g(σ1) - g(σ2)]*I
- This looks a lot like our LoG!
- (not actually the same but similar)
DoG (1 - 0)
DoG (2 - 1)
Another approach: gradient magnitude
- Don’t need 2nd derivatives
- Just use magnitude of gradient
Another approach: gradient magnitude
- Don’t need 2nd derivatives
- Just use magnitude of gradient
- Are we done? No!
What we really want: line drawing
Canny Edge Detection
- Your first image processing pipeline!
- Old-school CV is all about pipelines
Algorithm:
- Smooth image (only want “real” edges, not noise)
- Calculate gradient direction and magnitude
- Non-maximum suppression perpendicular to edge
- Threshold into strong, weak, no edge
- Connect together components
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Smooth image
- You know how to do this, gaussians!
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Gradient magnitude and direction
- Sobel filter
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Non-maximum suppression
- Want single pixel edges, not thick blurry lines
- Need to check nearby pixels
- See if response is highest
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Non-maximum suppression
Non-maximum suppression
Non-maximum suppression
Non-maximum suppression
Non-maximum suppression
Non-maximum suppression
Non-maximum suppression
Non-maximum suppression
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Threshold edges
- Still some noise
- Only want strong edges
- 2 thresholds, 3 cases
- R > T: strong edge
- R < T but R > t: weak edge
- R < t: no edge
- Why two thresholds?
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Connect ‘em up!
- Strong edges are edges!
- Weak edges are edges
iff they connect to strong
- Look in some neighborhood
(usually 8 closest)
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Canny Edge Detection
- Your first image processing pipeline!
- Old-school CV is all about pipelines
Algorithm:
- Smooth image (only want “real” edges, not noise)
- Calculate gradient direction and magnitude
- Non-maximum suppression perpendicular to edge
- Threshold into strong, weak, no edge
- Connect together components
- Tunable: Sigma, thresholds
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Canny Edge Detection
http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/
Effect of σ (Gaussian kernel spread/size)
• http://bigwww.epfl.ch/demo/ip/demos/edgeDetector/