hough transform
play

Hough Transform 16-385 Computer Vision (Kris Kitani) Carnegie - PowerPoint PPT Presentation

Hough Transform 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University motivation Original image Edge detection Thresholding How do we find image boundaries (lines)? Hough Transform Generic framework for detecting a shape/object


  1. Hough Transform 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University

  2. motivation Original image Edge detection Thresholding How do we find image boundaries (lines)?

  3. Hough Transform • Generic framework for detecting a shape/object • Edges don’t have to be connected • Lines can be occluded • Key idea: edges vote for the possible models

  4. Image and parameter space variables variables y = mx + b y − mx = b parameters parameters b y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes a point -5 -4 -3 -2 -1 0 1 2 3 4 -5 -4 -3 -2 -1 0 1 2 3 4 x m -1 -1 -2 -2 -3 -3 -4 -4 Parameter space Image space

  5. Image and parameter space variables variables y = mx + b y − mx = b parameters parameters b y 4 4 3 3 2 2 (1 , 1) a point 1 1 becomes a line -5 -4 -3 -2 -1 0 1 2 3 4 x -5 -4 -3 -2 -1 0 1 2 3 4 m -1 -1 -2 -2 -3 -3 -4 -4 Parameter space Image space

  6. Image and parameter space variables variables y = mx + b y − mx = b parameters parameters b y 4 4 (3 , 3) 3 3 2 2 (1 , 1) two points 1 1 become ? -5 -4 -3 -2 -1 0 1 2 3 4 x -5 -4 -3 -2 -1 0 1 2 3 4 m -1 -1 -2 -2 -3 -3 -4 -4 Parameter space Image space

  7. Image and parameter space variables variables y = mx + b y − mx = b parameters parameters b y 4 4 (3 , 3) 3 3 2 2 (1 , 1) two points 1 1 become ? -5 -4 -3 -2 -1 0 1 2 3 4 x -5 -4 -3 -2 -1 0 1 2 3 4 m -1 -1 -2 -2 -3 -3 -4 -4 Parameter space Image space

  8. Image and parameter space variables variables y = mx + b y − mx = b parameters parameters b y 4 4 (3 , 3) 3 3 2 2 (1 , 1) three points 1 1 become -5 -4 -3 -2 -1 0 1 2 3 4 x -5 -4 -3 -2 -1 0 1 2 3 4 ? m -1 -1 ( − 2 , − 2) -2 -2 -3 -3 -4 -4 Parameter space Image space

  9. Image and parameter space variables variables y = mx + b y − mx = b parameters parameters b y 4 4 (3 , 3) 3 3 2 2 (1 , 1) four points 1 1 become -5 -4 -3 -2 -1 0 1 2 3 4 x -5 -4 -3 -2 -1 0 1 2 3 4 ? m -1 -1 ( − 2 , − 2) (1 , − 1) -2 -2 -3 -3 -4 -4 Parameter space Image space

  10. Image and parameter space variables variables y = mx + b y − mx = b parameters parameters b y 4 4 (3 , 3) 3 3 2 2 (1 , 1) four points 1 1 become -5 -4 -3 -2 -1 0 1 2 3 4 x -5 -4 -3 -2 -1 0 1 2 3 4 ? m -1 -1 ( − 2 , − 2) (1 , − 1) -2 -2 -3 -3 -4 -4 Parameter space Image space

  11. How would you find the best fitting line? b y 4 4 (3 , 3) 3 3 2 2 (1 , 1) 1 1 -5 -4 -3 -2 -1 0 1 2 3 4 x -5 -4 -3 -2 -1 0 1 2 3 4 m -1 -1 ( − 2 , − 2) (1 , − 1) -2 -2 -3 -3 -4 -4 Image space Parameter space Is your method robust to measurement noise? Is your method robust to outliers?

  12. Line Detection by Hough Transform y Algorithm: ( m , c ) 1.Quantize Parameter Space ( m , c ) x 2.Create Accumulator Array Parameter Space A ( m , c ) A ( m , c ) A ( m , c ) 0 m , c 3.Set = ∀ 1 1 1 1 ( x i y , ) 4. For each image edge 
 1 1 i A ( m , c ) For each element in 
 2 1 1 ( m , c ) c x m y If lies on the line: 
 = − + 1 1 i i A ( m , c ) A ( m , c ) 1 1 1 Increment = + A ( m , c ) 5. Find local maxima in

  13. Problems with parameterization ( m , c ) What’s wrong with the parameterization ? How big does the accumulator need to be? 1 1 1 1 1 1 2 A ( m , c ) 1 1 1 1 1 1

  14. Problems with parameterization ( m , c ) What’s wrong with the parameterization ? How big does the accumulator need to be? 1 1 1 1 1 1 2 A ( m , c ) 1 1 1 1 1 1 The space of m is huge! The space of c is huge!

  15. Problems with parameterization ( m , c ) What’s wrong with the parameterization ? How big does the accumulator need to be? 1 1 1 1 1 1 2 A ( m , c ) 1 1 1 1 1 1 The space of m is huge! The space of c is huge! m − ∞ ≤ ≤ ∞

  16. Better Parameterization y Use normal form: x cos θ + y sin θ = ρ ( x i y , ) i ( , ) ( x i y , ) ρ θ Given points find i x Image Space Hough Space Sinusoid ρ 0 2 ≤ θ ≤ π ? 0 ≤ ρ ≤ ρ max (Finite Accumulator Array Size) θ Hough Space

  17. Image and parameter space variables parameters y = mx + b x cos θ + y sin θ = ρ parameters variables y ρ 4 4 3 3 2 2 (1 , 1) a point 1 1 becomes 0 a wave -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 θ 0.25 π 0.5 π 0.75 π Parameter space Image space

  18. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  19. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  20. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  21. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  22. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  23. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  24. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters Wait …why is rho negative? y 4 4 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  25. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 same line 4 through the point 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  26. y There are two ways to 4 3 write the same line: 2 (1 , 1) 1 ρ θ -5 -4 -3 -2 -1 0 1 2 3 4 x Positive rho version: -1 -2 x cos θ + y sin θ = ρ -3 -4 y Negative rho version: 4 3 2 x cos( θ + π ) + y sin( θ + π ) = − ρ (1 , 1) 1 θ + π -5 -4 -3 -2 -1 0 1 2 3 4 x − ρ -1 Recall: -2 sin( θ ) = − sin( θ + π ) -3 -4 cos( θ ) = − cos( θ + π )

  27. Image and parameter space variables y = mx + b x cos θ + y sin θ = ρ parameters y 4 same line 4 through the point 3 3 2 2 (1 , 1) a line 1 1 becomes 0 a point -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  28. Image and parameter space variables y = mx + b parameters y 4 4 (3 , 3) 3 3 2 2 (1 , 1) two points 1 1 become 0 ? -5 -4 -3 -2 -1 0 1 2 3 4 x -1 -1 -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  29. Image and parameter space variables y = mx + b parameters y 4 4 (3 , 3) 3 3 2 2 (1 , 1) three points 1 1 become 0 -5 -4 -3 -2 -1 0 1 2 3 4 x ? -1 -1 ( − 2 , − 2) -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  30. Image and parameter space variables y = mx + b parameters y 4 4 (3 , 3) 3 3 2 2 (1 , 1) four points 1 1 become 0 -5 -4 -3 -2 -1 0 1 2 3 4 x ? -1 -1 ( − 2 , − 2) (1 , − 1) -2 -2 -3 -3 -4 -4 0.25 π 0.5 π 0.75 π Parameter space Image space

  31. implementation 1. Initialize accumulator H to all zeros 2. For each edge point (x,y) in the image 
 For θ = 0 to 180 
 ρ = x cos θ + y sin θ 
 H( θ , ρ ) = H( θ , ρ ) + 1 
 end 
 end 3. Find the value(s) of ( θ , ρ ) where H( θ , ρ ) is a local maximum 4. The detected line in the image is given by 
 ρ = x cos θ + y sin θ NOTE: Watch your coordinates. Image origin is top left!

  32. Image space Votes

  33. Basic shapes (in polar parameter space) can you guess the shape?

  34. Basic shapes (in polar parameter space) line rectangle circle

  35. Basic Shapes

  36. More complex image

  37. In practice, measurements are noisy… Image space Votes

  38. Too much noise … Image space Votes

Recommend


More recommend