Canny Edge and Line Detection - Scientific Computing and...
Transcript of Canny Edge and Line Detection - Scientific Computing and...
![Page 1: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/1.jpg)
Canny Edge and Line Detection
CS/BIOEN 6640, Fall 2010Guido Gerig
with some slides from Tsai Sing Leewith some slides from Tsai Sing Lee, CMU and from J. Canny’s Papers
![Page 2: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/2.jpg)
![Page 3: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/3.jpg)
![Page 4: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/4.jpg)
![Page 5: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/5.jpg)
![Page 6: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/6.jpg)
![Page 7: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/7.jpg)
“Optimal Operator” for Noisy Step p p y pEdge: SNR*LOC
![Page 8: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/8.jpg)
![Page 9: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/9.jpg)
OptimizationOptimization
∑ Λ∑ Λ r
∑: SNR
Λ: Localization (how close to true position)
X max: distance between adjacent maxima (fraction of operator width)X_max: distance between adjacent maxima (fraction of operator width)
r: multiple response performance
![Page 10: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/10.jpg)
Optimal OperatorsOptimal Operators
∑ Λ r
X_max_
![Page 11: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/11.jpg)
Optimal Operator versus First D i i f G iDerivative of Gaussian
![Page 12: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/12.jpg)
“Optimal Operator” for Noisy Step p p y pEdge: SNR*LOC*MULT
![Page 13: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/13.jpg)
2D Edge Filter: Output at different scales
1st order Gaussian Derivatives
![Page 14: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/14.jpg)
Response at different scalesResponse at different scales
![Page 15: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/15.jpg)
Non-Maximum SuppressionNon Maximum Suppression
Detect local maxima and suppress all other signals.
![Page 16: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/16.jpg)
What about 2D?What about 2D?
At every position in the edge-
original edge orientation
edgeAt every position in the edgemagnitude output, there is a coordinate system with normal and tangent.
edge positions coded by edge
it dmagnitude
![Page 17: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/17.jpg)
Non-Maximum Suppression
• Canny: Interpolate Gradient along
Non Maximum Suppression
Canny: Interpolate Gradient along gradients (plus and minus a certain distance) and check if center is larger than neighbors.
• Simplified: Test for each Gradient BMagnitude pixel if neighbors along
gradient direction (closest neighbors) are smaller than center: Mark C as
B
are smaller than center: Mark C as maximum if A<C and B<C C
A
![Page 18: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/18.jpg)
![Page 19: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/19.jpg)
![Page 20: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/20.jpg)
![Page 21: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/21.jpg)
![Page 22: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/22.jpg)
ResultsResults
![Page 23: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/23.jpg)
![Page 24: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/24.jpg)
![Page 25: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/25.jpg)
Canny: Hysteresis ThresholdingCanny: Hysteresis Thresholding
• Thresholding/binarization of edge map:Thresholding/binarization of edge map:– Noise and image structures have different
structurestructure– Simple thresholding: If too low, too many
structures appear, if too high, contours arestructures appear, if too high, contours are broken into pieces
– Idea: Hysteresis: Upper and lower threshold, y pp ,keep all connected edges (dm metric) that are connected to upper but above lower threshold
![Page 26: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/26.jpg)
Hysteresis ThresholdingHysteresis Thresholding
ttoo little
too many
combitimany nation
![Page 27: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/27.jpg)
![Page 28: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/28.jpg)
Optimal Operators for Other SStructures
Resembles 2nd derivative of Gaussian
![Page 29: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/29.jpg)
Gaussian DerivativesGaussian Derivatives
![Page 30: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/30.jpg)
2nd Derivative Operator to detect lines and curves
![Page 31: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/31.jpg)
Multidimensional DerivativesMultidimensional Derivatives
• Nabla operator:Nabla operator:
• Gradient:
• Laplacian:
• Hessian:
(matrix of 2nd derivatives, gradient of gradient of L)
![Page 32: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/32.jpg)
LaplacianLaplacian
Local kernels
Laplacian of 2D Gaussian kernel
![Page 33: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/33.jpg)
Laplacian of Gaussian (LoG)Laplacian of Gaussian (LoG)
Enhances line-like structures (glasses), creates zero-crossing at edges (positive and negative response at both sides of edges)
Source: http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm
and negative response at both sides of edges)
![Page 34: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/34.jpg)
Often used: Zero-Crossings of LoG for Edge Detection
Hint: Remember that edge positions are extrema of first derivative → zero-crossings of 2nd derivatives. Be careful: Extrema or maxima & minima!
![Page 35: Canny Edge and Line Detection - Scientific Computing and ...gerig/CS6640-F2012/Materials/Canny-Gerig-Slides... · Canny Edge and Line Detection CS/BIOEN 6640, Fall 2010 Guido Gerig](https://reader035.fdocuments.net/reader035/viewer/2022062306/5ad52a837f8b9a075a8c930a/html5/thumbnails/35.jpg)
Line/Ridge DetectionLine/Ridge Detection