Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough...
-
Upload
chester-tate -
Category
Documents
-
view
221 -
download
0
Transcript of Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough...
![Page 1: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/1.jpg)
Computational Vision / Ioannis StamosComputational Vision / Ioannis Stamos
Edge DetectionEdge Detection Canny DetectorCanny Detector
Line DetectionLine Detection Hough TransformHough Transform
Trucco: Chapter 4, pp. 76 – 80Trucco: Chapter 4, pp. 76 – 80
Chapter 5, pp. 95 - 100Chapter 5, pp. 95 - 100
Computational VisionComputational Vision
![Page 2: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/2.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding Corners Finding Corners
![Page 3: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/3.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
What Is a Corner?What Is a Corner?
Large gradients in more than one direction.
![Page 4: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/4.jpg)
Edges vs. CornersEdges vs. Corners
Edges = maxima in intensity gradientEdges = maxima in intensity gradient
![Page 5: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/5.jpg)
Edges vs. CornersEdges vs. Corners
Corners = lots of variation in direction of Corners = lots of variation in direction of gradient in a small neighborhoodgradient in a small neighborhood
![Page 6: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/6.jpg)
Detecting CornersDetecting Corners
How to detect this variation?How to detect this variation?
![Page 7: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/7.jpg)
Detecting CornersDetecting Corners
How to detect this variation?How to detect this variation? Not enough to check average andNot enough to check average and
x
f
x
f
y
f
y
f
![Page 8: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/8.jpg)
Detecting CornersDetecting Corners
Claim: the following covariance matrix Claim: the following covariance matrix summarizes the statistics of the gradientsummarizes the statistics of the gradient
Summations over local neighborhoodsSummations over local neighborhoods
y
ff
x
ff
fff
fffC yx
yyx
yxx
,2
2
y
ff
x
ff
fff
fffC yx
yyx
yxx
,2
2
![Page 9: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/9.jpg)
Detecting CornersDetecting Corners
Examine behavior of Examine behavior of CC by testing its effect by testing its effect in simple casesin simple cases
Case #1: Single edge in local Case #1: Single edge in local neighborhoodneighborhood
![Page 10: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/10.jpg)
Case#1: Single EdgeCase#1: Single Edge
Let (Let (aa,,bb) be gradient along edge) be gradient along edge Compute Compute CC ((aa,,bb):):
b
aff
b
aff
b
a
fff
fff
b
aC
yyx
yxx
T
2
2
b
aff
b
aff
b
a
fff
fff
b
aC
yyx
yxx
T
2
2
y
x
f
ff
y
x
f
ff
![Page 11: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/11.jpg)
Case #1: Single EdgeCase #1: Single Edge
However, in this simple case, the only However, in this simple case, the only nonzero terms are those where nonzero terms are those where ff = ( = (aa,,bb))
So, So, CC ((aa,,bb) is just some multiple of () is just some multiple of (aa,,bb))
![Page 12: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/12.jpg)
Case #2: CornerCase #2: Corner
Assume there is a corner, with Assume there is a corner, with perpendicular gradients (perpendicular gradients (aa,,bb) and () and (cc,,dd))
![Page 13: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/13.jpg)
Case #2: CornerCase #2: Corner
What is What is CC ((aa,,bb)?)? Since (Since (aa,,bb) ) ( (cc,,dd) = 0, the only nonzero terms ) = 0, the only nonzero terms
are those where are those where ff = ( = (aa,,bb)) So, So, CC ((aa,,bb) is again just a multiple of () is again just a multiple of (aa,,bb))
What is What is CC ((cc,,dd)?)? Since (Since (aa,,bb) ) ( (cc,,dd) = 0, the only nonzero terms ) = 0, the only nonzero terms
are those where are those where ff = ( = (cc,,dd)) So, So, CC ((cc,,dd) is a multiple of () is a multiple of (cc,,dd))
![Page 14: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/14.jpg)
Corner DetectionCorner Detection
Matrix times vector = multiple of vectorMatrix times vector = multiple of vector Eigenvectors and eigenvalues!Eigenvectors and eigenvalues! In particular, if In particular, if CC has has oneone large large
eigenvalue, there’s an edgeeigenvalue, there’s an edge If If CC has has twotwo large eigenvalues, have large eigenvalues, have
cornercorner Tomasi-Kanade corner detectorTomasi-Kanade corner detector
![Page 15: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/15.jpg)
Corner Detection Corner Detection Implementation Implementation
1.1. Compute image gradientCompute image gradient
2.2. For each For each mmmm neighborhood, neighborhood,compute matrix compute matrix CC
3.3. If smaller eigenvalue If smaller eigenvalue 22 is larger than is larger than
threshold threshold , record a corner, record a corner
4.4. Nonmaximum suppression: only keep Nonmaximum suppression: only keep strongest corner in each strongest corner in each mmmm window window
![Page 16: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/16.jpg)
Corner Detection ResultsCorner Detection Results
CheckerboardCheckerboardwith noisewith noise
Trucco & VerriTrucco & Verri
![Page 17: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/17.jpg)
Corner Detection ResultsCorner Detection Results
![Page 18: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/18.jpg)
Corner Detection ResultsCorner Detection Results
Histogram of Histogram of 22 (smaller eigenvalue (smaller eigenvalue))
![Page 19: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/19.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
A Simple Corner DetectorA Simple Corner Detector
2
2
yyx
yxx
III
IIIC
21 Find eigenvalues of C
If the smaller eigenvalue is above a threshold then we have a corner.
![Page 20: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/20.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
A Simple Corner DetectorA Simple Corner Detector
2
2
yyx
yxx
III
IIIC
21 Find eigenvalues of C
If the smaller eigenvalue is above a threshold then we have a corner.
0yI
00
0aC
a
aC
0
0
![Page 21: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/21.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
A Simple Corner DetectorA Simple Corner Detector
![Page 22: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/22.jpg)
Canny Edge DetectionCanny Edge Detection Can we derive an optimal detector?Can we derive an optimal detector? Good Detection:Good Detection: minimize false positives and false negatives. minimize false positives and false negatives. Good Localization:Good Localization: close as possible to the true edges. close as possible to the true edges. Single Response Constraint:Single Response Constraint: one edge should be detected one edge should be detected
for each true edgefor each true edge
![Page 23: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/23.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
ComparisonComparison
CannySobel
![Page 24: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/24.jpg)
Canny Edge DetectionCanny Edge Detection
3 STEPS:3 STEPS: CANNY_ENHANCERCANNY_ENHANCER NONMAX_SUPPRESIONNONMAX_SUPPRESION HYSTERESIS_THRESHHYSTERESIS_THRESH
![Page 25: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/25.jpg)
Localization-Detection TradeoffLocalization-Detection Tradeoff
Filter’s spatial scale Filter’s spatial scale Location &Location & Detection criteria.Detection criteria.
Good tradeoff 1-D step edge detector:Good tradeoff 1-D step edge detector:
(optimal)(optimal) Approximated by the 1Approximated by the 1stst derivative of the Gaussian. derivative of the Gaussian.
![Page 26: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/26.jpg)
Optimal 1-D step edge detectors…
Pixel (i,j)
Keep the one that gives you maximum response.
Expensive.
![Page 27: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/27.jpg)
Solution…
Pixel (i,j)
Compute derivatives with respect to x & y directions.
Compute edge normal.
x
y
![Page 28: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/28.jpg)
CANNY_ENHANCERCANNY_ENHANCER Compute Compute IIxx and and IIyy the gradient of the image using a derivative of the gradient of the image using a derivative of
Gaussian filter.Gaussian filter. Compute the edge strength from the magnitude of the gradient: Compute the edge strength from the magnitude of the gradient:
EsEs
Compute the orientation of the edge from arctan(Compute the orientation of the edge from arctan(IIyy / / IIxx ): ): EoEo
[Canny ’86]n
![Page 29: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/29.jpg)
• Compute image derivatives • if gradient magnitude > and the value is a local max. along gradient direction – pixel is an edge candidate• how to detect one pixel thin edges ?
gradient magnitude (Es)original image
Problem with detectorProblem with detector
![Page 30: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/30.jpg)
NONMAX_SUPPRESSIONNONMAX_SUPPRESSION
0
4590
135
Locate local maxima from Es.
•Find direction d that best approximates Eo(i,j)•If Es(i,j) is smaller than at least one neighbor along d In(i,j)=0 else In(i,j)=Es(i,j).
![Page 31: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/31.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Non-Maximum SupressionNon-Maximum Supression
Non-maximum suppression:Select the single maximum point across the width of an edge.
![Page 32: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/32.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Linking to the Next Edge PointLinking to the Next Edge Point
Assume the marked point q is an edge point.
Take the normal to the gradient at that point and use this to predict continuation points (either r or p).
![Page 33: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/33.jpg)
ThresholdingThresholding Edges are found by thresholding the output of Edges are found by thresholding the output of
NONMAX_SUPRESSIONNONMAX_SUPRESSION If the threshold is too high:If the threshold is too high:
Very few (none) edges Very few (none) edges High MISDETECTIONS, many gapsHigh MISDETECTIONS, many gaps
If the threshold is too low:If the threshold is too low: Too many (all pixels) edgesToo many (all pixels) edges
High FALSE POSITIVES, many extra edgesHigh FALSE POSITIVES, many extra edges
![Page 34: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/34.jpg)
Edge Detection With HysteresisEdge Detection With Hysteresis
Low threshold High threshold
Hysteresis (high and low threshold)
![Page 35: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/35.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Edge HysteresisEdge Hysteresis
HysteresisHysteresis:: A lag or momentum factorA lag or momentum factor Idea: Maintain two thresholds Idea: Maintain two thresholds kkhighhigh and and kklowlow
Use Use kkhighhigh to find strong edges to start edge to find strong edges to start edge
chainchain Use Use kklowlow to find weak edges which to find weak edges which
continue edge chaincontinue edge chain Typical ratio of thresholds is roughlyTypical ratio of thresholds is roughly
kkhighhigh // kklowlow == 22
![Page 36: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/36.jpg)
Edge TrackingEdge TrackingHysteresis thresholding [Canny ’86]
Strong edge
Weak edges
Strong edges reinforce weak edges.
We call a pixel an edge if it is strong.We also call a pixel an edge if it is weak but is connected to an edge.A pixel is connected to an edge if it is in a direction perpendicular to the edge normal
Weak edge removed
edges
![Page 37: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/37.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Canny Edge Detection (Example)Canny Edge Detection (Example)
courtesy of G. Loy
gap is gone
Originalimage
Strongedges
only
Strong +connectedweak edges
Weakedges
![Page 38: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/38.jpg)
HYSTERESIS_THRESHHYSTERESIS_THRESH
Input: In, Eo, high threshold, low threshold.Input: In, Eo, high threshold, low threshold. Output: Lists of connected edges Output: Lists of connected edges
(contours).(contours).
![Page 39: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/39.jpg)
Edge RelaxationEdge RelaxationParallel – iterative method to adjust edge values on the basis of neighboring edges
Crack edges:
![Page 40: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/40.jpg)
Edge RelaxationEdge RelaxationParallel – iterative method to adjust edge values on the basis of neighboring edges
Vertex types:
Notation:Edge to be updated
Edge
No edge
Crack edges:
(0)
(1)
(2)
(3)
![Page 41: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/41.jpg)
Edge RelaxationEdge RelaxationParallel – iterative method to adjust edge values on the basis of neighboring edges
Vertex types:
Notation:Edge to be updated
Edge
No edge
Crack edges:
(0)
(1)
(2)
(3)
Action table for edge type:
Decrease Increase Unchanged 0-0 1-1 0-1 0-2 1-2 2-2 0-3 1-3 2-3
3-3
![Page 42: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/42.jpg)
Edge RelaxationEdge RelaxationParallel – iterative method to adjust edge values on the basis of neighboring edges
Vertex types:
Notation:Edge to be updated
Edge
No edge
Crack edges:
(0)
(1)
(2)
(3)
Action table for edge type:
Decrease Increase Unchanged 0-0 1-1 0-1 0-2 1-2 2-2 0-3 1-3 2-3
3-3
Algorithm:
0. Compute initial confidence C0(e) of each edge e C0(e) =
1. k = 1
2. Compute edge type for all e
3. Modify Ck(e) based on Ck-1(e) and edge type.
4. If all Ck(e) have converged to 1 or 0 else go to step 1
)max( I
e
![Page 43: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/43.jpg)
Computational Vision / Ioannis StamosComputational Vision / Ioannis Stamos
Canny Edge DetectorCanny Edge Detector
Original: LenaOriginal: Lena EdgesEdges
![Page 44: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/44.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Towards Global FeaturesTowards Global Features
Local versus global
![Page 45: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/45.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
From Edges to LinesFrom Edges to Lines
![Page 46: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/46.jpg)
Detecting LinesDetecting Lines
What is the difference between line What is the difference between line detection and edge detection?detection and edge detection? Edges = localEdges = local Lines = nonlocalLines = nonlocal
Line detection usually performed on the Line detection usually performed on the output of an edge detectoroutput of an edge detector
From Szymon Rusinkiewicz, Princeton
![Page 47: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/47.jpg)
Detecting LinesDetecting Lines
Possible approaches ?Possible approaches ?
From Szymon Rusinkiewicz, Princeton
![Page 48: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/48.jpg)
Detecting LinesDetecting Lines
Possible approaches:Possible approaches: Brute force: enumerate all lines, check if presentBrute force: enumerate all lines, check if present Hough transform: vote for lines to which detected Hough transform: vote for lines to which detected
edges might belongedges might belong Fitting: given guess for approximate location, refine itFitting: given guess for approximate location, refine it
Second method efficient for finding Second method efficient for finding unknown lines, but not always accurateunknown lines, but not always accurate
From Szymon Rusinkiewicz, Princeton
![Page 49: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/49.jpg)
Hough TransformHough Transform
General idea: transform from image General idea: transform from image coordinates to parameter space of featurecoordinates to parameter space of feature Need parameterized model of featuresNeed parameterized model of features For each pixel, determine all parameter values that For each pixel, determine all parameter values that
might have given rise to that pixel; votemight have given rise to that pixel; vote
At end, look for peaks in parameter spacAt end, look for peaks in parameter spacee
From Szymon Rusinkiewicz, Princeton
![Page 50: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/50.jpg)
Hough Transform for LinesHough Transform for Lines
Generic line: Generic line: y y = = axax++bb Parameters: Parameters: aa and and bb
From Szymon Rusinkiewicz, Princeton
![Page 51: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/51.jpg)
Hough Transform for LinesHough Transform for Lines
1.1. Initialize table of Initialize table of bucketsbuckets, indexed by, indexed byaa and and bb, to zero, to zero
2.2. For each detected edge pixel (For each detected edge pixel (xx,,yy):):a.a. Determine all (Determine all (aa,,bb) such that ) such that y y = = axax++bb
b.b. Increment bucket (Increment bucket (aa,,bb))
3.3. Buckets with many votes indicate probable linesBuckets with many votes indicate probable lines
From Szymon Rusinkiewicz, Princeton
![Page 52: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/52.jpg)
Hough Transform for LinesHough Transform for Lines
bb
aa
From Szymon Rusinkiewicz, Princeton
![Page 53: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/53.jpg)
Hough Transform for LinesHough Transform for Lines
bb
aa
From Szymon Rusinkiewicz, Princeton
![Page 54: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/54.jpg)
Difficulties withDifficulties withHough Transform for LinesHough Transform for Lines
Slope / intercept parameterization not idealSlope / intercept parameterization not ideal Non-uniform sampling of directionsNon-uniform sampling of directions Can’t represent vertical linesCan’t represent vertical lines
Angle / distance parameterizationAngle / distance parameterization Line represented as (Line represented as (rr,,) where) where
xx cos cos + + yy sin sin = = rr
rr
From Szymon Rusinkiewicz, Princeton
![Page 55: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/55.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding Lines Using the Hough Finding Lines Using the Hough TransformTransform
sincos ii yx
ii yx ,
![Page 56: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/56.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
AlgorithmAlgorithm Discretize the parameter spaces Discretize the parameter spaces ρ and θ.ρ and θ. Create Accumulator array A(1..R,1..T).Create Accumulator array A(1..R,1..T). Set A(k,h)=0 for all k and h.Set A(k,h)=0 for all k and h. For each image edge E(i,j)=1For each image edge E(i,j)=1
For h=1…TFor h=1…T ρ =i cosθρ =i cosθdd(h)+j sinθ(h)+j sinθd d (h)(h) Find index k: ρFind index k: ρd d is closest to ρis closest to ρ Increment A(h,k) by one.Increment A(h,k) by one.
Find all local maxima (kFind all local maxima (kpp, h, hpp) such that A (k) such that A (kpp, h, hpp)>τ)>τ
![Page 57: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/57.jpg)
Hough Transform ResultsHough Transform Results
Forsyth & PonceForsyth & Ponce
![Page 58: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/58.jpg)
Hough Transform ResultsHough Transform Results
Forsyth & PonceForsyth & Ponce
![Page 59: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/59.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding Lines Using the Hough Finding Lines Using the Hough TransformTransform
Strong local peaks correspond to lines.
![Page 60: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/60.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding Lines Using the Hough Finding Lines Using the Hough TransformTransform
Resolution Issues
…
![Page 61: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/61.jpg)
Bucket SelectionBucket Selection
How to select bucket size?How to select bucket size?
From Szymon Rusinkiewicz, Princeton
![Page 62: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/62.jpg)
Bucket SelectionBucket Selection
How to select bucket size?How to select bucket size? Too small: poor performance on noisy data, long Too small: poor performance on noisy data, long
running timesrunning times Too large: poor accuracy, possibility of false positivesToo large: poor accuracy, possibility of false positives
Large buckets + verification and refinementLarge buckets + verification and refinement Problems distinguishing nearby linesProblems distinguishing nearby lines
Be smarter at selecting bucketsBe smarter at selecting buckets Use gradient information to select subset of bucketsUse gradient information to select subset of buckets More sensitive to noiseMore sensitive to noise
From Szymon Rusinkiewicz, Princeton
![Page 63: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/63.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Hough Transform: ResultsHough Transform: Results
Hough TransformImage Edge detection
![Page 64: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/64.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Summary Hough TransformSummary Hough Transform Smart countingSmart counting
Local evidence for global featuresLocal evidence for global features Organized in a tableOrganized in a table Careful with parameterization!Careful with parameterization!
Problem: Curse of dimensionalityProblem: Curse of dimensionality Works great for simple features with 3 unknownsWorks great for simple features with 3 unknowns Will fail for complex objectsWill fail for complex objects
Problem: Not a local algorithm Problem: Not a local algorithm
![Page 65: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/65.jpg)
Hough TransformHough Transform
What else can be detected usingWhat else can be detected usingHough transform?Hough transform?
![Page 66: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/66.jpg)
Hough TransformHough Transform
What else can be detected usingWhat else can be detected usingHough transform?Hough transform?
Anything, but Anything, but dimensionality dimensionality is keyis key
![Page 67: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/67.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding Circles by Hough TransformFinding Circles by Hough Transform
a0
b0r
(xi,yi)
Equation of Circle: 220
20 )()( rbyax ii
x
y
![Page 68: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/68.jpg)
Finding Circles by Hough TransformFinding Circles by Hough Transform
a0
b0r
(xi,yi)
Equation of Circle: 220
20 )()( rbyax ii
If radius r is known:
x
y
x
y
a
b
(xi,yi)
Circles!
Accumulator array A(a,b)
![Page 69: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/69.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding Circles by Hough TransformFinding Circles by Hough Transform
a0
b0r
(xi,yi)
x
y
If r is not knownUse accumulator array A(a,b,r)
For each (xi,yi) increment A(a,b,r) such that222 )()( rbyax ii
![Page 70: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/70.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Using Gradient InformationUsing Gradient InformationCan save lot of computations!
Given: location (xi,yi)Edge direction φi
x
y
![Page 71: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/71.jpg)
Using Gradient InformationUsing Gradient InformationCan save lot of computations!
Given: location (xi,yi)Edge direction φi
x
y
Assume r is known:
x
y φi
(xi,yi) a=x-rcosφ b=y-rsinφNeed to incrementonly one pointin Accumulator Array.
(a,b)
![Page 72: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/72.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Hough Transform for CurvesHough Transform for Curves
Curve y=f(x,Curve y=f(x,aa)) a=a=[a[a11, … , a, … , app] the parameters of the curve.] the parameters of the curve. Limitation: size of parameter space wrt # of Limitation: size of parameter space wrt # of
parameters.parameters. Solution: variable-resolution parameter space.Solution: variable-resolution parameter space.
![Page 73: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/73.jpg)
Hough TransformHough Transform
Pattern Matching.Pattern Matching. More efficient than template matching.More efficient than template matching. Handles occlusion.Handles occlusion. Finds all instances of patternFinds all instances of pattern.. Handling inaccurate edge locations?Handling inaccurate edge locations? Drawbacks?Drawbacks?
![Page 74: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/74.jpg)
FittingFitting
Output of Hough transform often not Output of Hough transform often not accurate enoughaccurate enough
Use as initial guess for fittingUse as initial guess for fitting
![Page 75: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/75.jpg)
Fitting LinesFitting Lines
Initial guessInitial guess
![Page 76: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/76.jpg)
Fitting LinesFitting Lines
Least-squaresLeast-squaresminimizationminimization
![Page 77: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/77.jpg)
Fitting LinesFitting Lines
![Page 78: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/78.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding LinesFinding Lines
Assume edge detectionAssume edge detection Each pixel is either edge or notEach pixel is either edge or not How do we find the line?How do we find the line?
![Page 79: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/79.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Finding LinesFinding Lines
Assume edge detectionAssume edge detection Each pixel is either edge or notEach pixel is either edge or not How do we find the line?How do we find the line?
![Page 80: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/80.jpg)
CSc 83020 3-D Computer Vision – Ioannis StamosCSc 83020 3-D Computer Vision – Ioannis Stamos
Least Squares Fitting of LinesLeast Squares Fitting of Linescmxy
ii yx ,
cmxy ii
i
ii
N
cmxyE
2
Minimize E
0
0
c
Em
E
![Page 81: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/81.jpg)
Least Squares Fitting of LinesLeast Squares Fitting of Lines
i
ii
N
cmxyE
2
Minimize E
0
0
c
Em
E
Problem: E must be formulated carefully!
![Page 82: Computational Vision / Ioannis Stamos Edge Detection Canny Detector Line Detection Hough Transform Trucco: Chapter 4, pp. 76 – 80 Chapter 5,](https://reader037.fdocuments.us/reader037/viewer/2022102818/56649f4f5503460f94c70f85/html5/thumbnails/82.jpg)
Least Squares Fitting of LinesLeast Squares Fitting of Lines
ii yx ,
i
ii
N
yxE
2cossin
Minimize E
0
0
E
E
0cossin yx
cossin ii yx