![Page 1: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/1.jpg)
– Most widely used edge detector in computer vision.
– First derivative of the Gaussian closely approximates the operator that optimizes the product of signal-to-noise ratio and localization.
– Analysis based on "step-edges" corrupted by "additive Gaussian noise".
Canny Edge Detection
Least squares with binomial weights ~~~ edge detector.
J. Canny, A Computational Approach To Edge Detection. IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986.
![Page 2: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/2.jpg)
Edge Detection Criteria
– Good detection accuracy: • minimize the probability of false positives (detecting spurious
edges caused by noise), • false negatives (missing real edges)
– Good localization:
• edges must be detected as close as possible to the true edges.
– Single response constraint:
• minimize the number of local maxima around the true edge (i.e. detector must return single point for each true edge point)
• Criteria for optimal edge detection (Canny 86):
![Page 3: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/3.jpg)
• Examples... valid mostly for straight edges...
True edge Poor
localization Too many responses
Poor robustness to noise
![Page 4: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/4.jpg)
Canny Edge Detection Steps:
1+2. Gaussian smoothing together with derivative of Gaussian (~discrete)
3. Find magnitude and orientation of gradient
4. Extract edge points: Non-maximum suppression
5. Linking and thresholding: Hysteresis
• MATLAB: edge(I, ‘canny’)
![Page 5: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/5.jpg)
First Two Steps
• Smoothing
I)y,x(g'I 2
22
2
2
1),(
yx
eyxg
IgIgS
y
x
g
g
y
gx
g
gIg
g
y
x
Ig
Ig
y
x
•Derivative Can be done with two one-dimensional filters.
2
![Page 6: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/6.jpg)
hx (x,y) =∂h(x,y)
∂x=
−x2πσ 4 e
−x 2 +y 2
2σ 2
hy (x,y) =∂h(x,y)
∂=
−2πσ 4 e
−x 2 +y 2
2σ 2
Scale
h = g
y
y
two dimensional Gaussian
![Page 7: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/7.jpg)
yx SSS
Example:
xS
yS
I
IgIgS
= gradient vector
![Page 8: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/8.jpg)
Increased smoothing: • Eliminates noise edges. • Makes edges smoother and thicker. • Removes fine detail.
sigma 1 pixel 2 pixels
![Page 9: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/9.jpg)
Third Step
• magnitude and direction of
x
y1
2
y
2
x
S
Standirection
)SS(magnitude
image gradient magnitude
yx SSS
![Page 10: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/10.jpg)
Non-maximum suppression along the
At q, we have a maximum if the value is larger than those at both p and at r. Interpolate to get these values.
Source: D. Forsyth
direction of gradient Fourth Step
![Page 11: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/11.jpg)
Example: Non-Maximum Suppression
courtesy of G. Loy
Original image Gradient magnitude Non-maxima suppressed
Slide credit: Christopher Rasmussen
![Page 12: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/12.jpg)
high threshold strong edges only
low threshold weak edges too
![Page 13: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/13.jpg)
• Hysteresis: no LOW maybe HIGH sure.• Maintain two thresholds khigh and klow
– Use khigh to find strong edges to start edge chain. – Use klow to find weak edges along the edge chain.
• Typical ratio of thresholds is roughly khigh / klow = 2 - 2.5
Fifth Step: Hysteresis Thresholding
![Page 14: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/14.jpg)
Closing edge gaps
• Check that maximum value of gradient value is sufficiently large and...... use hysteresis.
• use a high threshold to start edge curves and a low threshold to continue them.
Gra
dien
t m
agni
tude
t1
t2
Labeled as edge
Pixel number in linked list along gradient maxima
Not an edge
maybe
a line
![Page 15: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/15.jpg)
Example
courtesy of G. Loy
gap is gone
Original image
Strong edges
only
Strong + connected weak edges
Weak edgestoo
![Page 16: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/16.jpg)
Effect of (Gaussian kernel spread/size)
Canny with Canny with original
• The choice of depends on desired behavior – large detects large scale edges – small detects fine features
Source: S. Seitz
![Page 17: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/17.jpg)
Example of Canny edge detection
original image (Lena)
![Page 18: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/18.jpg)
Compute Gradients (DoG)
X-Derivative of Gaussian Y-Derivative of Gaussian Gradient Magnitude
and orientation
![Page 19: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/19.jpg)
Before non-max suppression...
![Page 20: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/20.jpg)
...after non-max suppression
![Page 21: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/21.jpg)
Before the hysteresis thresholding • Threshold at low/high levels to get weak/strong edge pixels
• Do connected components, starting from strong edge pixels
![Page 22: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/22.jpg)
Final Canny Edges
![Page 23: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/23.jpg)
A hidden advantage for the human observer.She/he first see the original image and onlyafter the edges detected. What happens if she/he cannot see the originalimage first and therefore can rely on it? This is how all the computer vision algorithms has to work... all the time!
![Page 24: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/24.jpg)
![Page 25: Canny Edge Detection - Rutgers Universityrci.rutgers.edu/~meer/GRAD561/ADD/cannyedge.pdf · Edge Detection Criteria –Good detection accuracy: • minimize the probability of false](https://reader030.vdocuments.us/reader030/viewer/2022021505/5ad52a837f8b9a075a8c92d5/html5/thumbnails/25.jpg)