Edge detection - Department of Computer Science at Illinois
Transcript of Edge detection - Department of Computer Science at Illinois
![Page 1: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/1.jpg)
Edge detection
• Goal: Identify sudden changes (discontinuities) inchanges (discontinuities) in an image• Intuitively, most semantic and shape
i f ti f th i binformation from the image can be encoded in the edges
• More compact than pixels
• Ideal: artist’s line drawing (but artist is also using(but artist is also using object-level knowledge)
Source: D. Lowe
![Page 2: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/2.jpg)
Origin of edges
Edges are caused by a variety of factors:
surface normal discontinuity
depth discontinuity
surface color discontinuity
illumination discontinuity
Source: Steve Seitz
![Page 3: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/3.jpg)
Characterizing edges• An edge is a place of rapid change in the
image intensity function
imageintensity function
(along horizontal scanline) first derivative
edges correspond toextrema of derivative
![Page 4: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/4.jpg)
Derivatives with convolutionFor 2D function f(x,y), the partial derivative is:
ε )()()( yxfyxfyxf +∂ε
εε
),(),(lim),(0
yxfyxfx
yxf −+=
∂∂
→
For discrete data, we can approximate using finite differences:
1),(),1(),( yxfyxf
xyxf −+
≈∂
∂
To implement above as convolution, what would be the associated filter?
1x∂
associated filter?
Source: K. Grauman
![Page 5: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/5.jpg)
Partial derivatives of an image
f∂ )( f∂ )(x
yxf∂
∂ ),(y
yxf∂
∂ ),(
1 1-1 1
1 -1or-1 1
Which shows changes with respect to x?
![Page 6: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/6.jpg)
Finite difference filtersOther approximations of derivative filters exist:
Source: K. Grauman
![Page 7: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/7.jpg)
Image gradient
The gradient of an image:
The gradient points in the direction of most rapid increase in intensity
Th di t di ti i i b
• How does this direction relate to the direction of the edge?
The gradient direction is given by
The edge strength is given by the gradient magnitude
Source: Steve Seitz
![Page 8: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/8.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?Source: S. Seitz
![Page 9: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/9.jpg)
Solution: smooth first
f
gg
f *f * g
d )( gfdxd
∗
• To find edges, look for peaks in )( gfdxd
∗Source: S. Seitz
![Page 10: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/10.jpg)
Derivative theorem of convolution• Differentiation is convolution, and convolution
is associative: gddfgf
dd
∗=∗ )(
• This saves us one operation:dxdx
f
gdd
df
gdx
gdxdf ∗
Source: S. Seitz
![Page 11: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/11.jpg)
Derivative of Gaussian filter
x-direction y-direction
Are these filters separable?
![Page 12: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/12.jpg)
Derivative of Gaussian filter
x-direction y-direction
Which one finds horizontal/vertical edges?
![Page 13: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/13.jpg)
Scale of Gaussian derivative filter
1 pixel 3 pixels 7 pixels
Smoothed derivative removes noise, but blurs edge Also finds edges at different “scales”edge. Also finds edges at different scales
Source: D. Forsyth
![Page 14: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/14.jpg)
Review: Smoothing vs. derivative filtersSmoothing filters
• Gaussian: remove “high-frequency” components; “l ” filt“low-pass” filter
• Can the values of a smoothing filter be negative?• What should the values sum to?
– One: constant regions are not affected by the filter
Derivative filters• Derivatives of Gaussian
C f f ?• Can the values of a derivative filter be negative?• What should the values sum to?
– Zero: no response in constant regions• High absolute value at points of high contrast
![Page 15: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/15.jpg)
The Canny edge detector
original imageSlide credit: Steve Seitz
![Page 16: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/16.jpg)
The Canny edge detector
norm of the gradient
![Page 17: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/17.jpg)
The Canny edge detector
thresholding
![Page 18: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/18.jpg)
The Canny edge detector
How to turnHow to turn these thick regions of the gradientthe gradient into curves?
thresholding
![Page 19: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/19.jpg)
Non-maximum suppression
Check if pixel is local maximum along gradient direction, select single max across width of , gthe edge• requires checking interpolated pixels p and r
![Page 20: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/20.jpg)
The Canny edge detector
Problem: pixels along this edge didn’t survive thesurvive the thresholding
thinning(non-maximum suppression)
![Page 21: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/21.jpg)
Hysteresis thresholding
Use a high threshold to start edge curves, and aUse a high threshold to start edge curves, and a low threshold to continue them.
Source: Steve Seitz
![Page 22: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/22.jpg)
Hysteresis thresholding
original image
high threshold(strong edges)
low threshold(weak edges)
hysteresis threshold
Source: L. Fei-Fei
![Page 23: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/23.jpg)
Recap: Canny edge detector
1. Filter image with derivative of Gaussian 2. Find magnitude and orientation of gradientg g3. Non-maximum suppression:
• Thin wide “ridges” down to single pixel width4. Linking and thresholding (hysteresis):
• Define two thresholds: low and high• Use the high threshold to start edge curves and
the low threshold to continue them
MATLAB d (i ‘ ’)MATLAB: edge(image, ‘canny’);
J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986.
![Page 24: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/24.jpg)
Edge detection is just the beginning…
image human segmentation gradient magnitude
Berkeley segmentation database:Berkeley segmentation database:http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/segbench/
![Page 25: Edge detection - Department of Computer Science at Illinois](https://reader031.fdocuments.us/reader031/viewer/2022020703/61fb2c372e268c58cd5b0350/html5/thumbnails/25.jpg)
Low-level edges vs. perceived contours
Background Texture ShadowsKristen Grauman, UT-Austin