110 likes | 248 Views
Lecture 6. Hough Transform. Detecting lines. y = mx + b 3 lines : y 1 = m 1 x + b 1 y 2 = m 2 x + b 2 y 3 = m 3 x + b 3. Detecting Lines. For example, Given 7 points, find m, b. Initial an empty array indexed by (m,b). Detecting Lines. 1. (0,1), 1 = 0+b b = 1 2. (1,2), 2 = m+b
E N D
Lecture 6 Hough Transform
Detecting lines y = mx + b 3 lines : y1 = m1x + b1 y2 = m2x + b2 y3 = m3x + b3
Detecting Lines • For example, Given 7 points, find m, b Initial an empty array indexed by (m,b)
Detecting Lines 1. (0,1), 1 = 0+b b = 1 2. (1,2), 2 = m+b b = 2 -m Max Vote - Peak in Hough Space Report (m,b) here 3. (1,3), 3 = m+b b = 3 - m 4. …… 5. …… … ... increase the array at each calculated (m,b)
Problem: Vertical Lines Solution: xcosq + ysinq q = 0 .. 359 degree
Hough Transform For Detecting Circles (x0,y0) - center, r - radius
Hough Transform For Detecting Circles a = ... b = … r = … For all a,b,r A[a,b,r]++ Problem: How to find peak in 3D array Clustering Algorithm
Hough Transform For Detecting Circles x = a + rcosq (1) y = b + rsinq (2) a = x - rcosq (3) b = y - rsinq (4) (1) *sinq xsinq = asinq + rsinqcosq (3) (2) *cosq ycosq = bcosq + rsinqcosq (4) (3) - (4) xsinq - ycosq = asinq - bcosq (5) (5) / cosq xtanq - y = atanq - b (6) b = (a-x)tanq + y
Hough Transform For Detecting Circles b = (a-x)tanq + y still have 3 unknowns : a, b, q Using Sobel Edge Detector: Finding Gx and Gy q q = gradient direction
bright dark Hough Transform For Detecting Circles Gradient Direction is perpendicular to edge direction q Known tanq at each edge element So, tanq is known There remains only 2 unknowns: a, b