1 / 31

Hough transform

Hough transform. Hough Transform. Introduced in 1962 by Paul Hough pronounced like “tough” according to http://www.citidel.org/bitstream/10117/1289/1/HoughTransform.html Detects lines. Has been generalized to other shapes as well. Handles noise. Handles partial occlusion.

Download Presentation

Hough transform

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hough transform

  2. Hough Transform • Introduced in 1962 by Paul Hough • pronounced like “tough” according to http://www.citidel.org/bitstream/10117/1289/1/HoughTransform.html • Detects lines. • Has been generalized to other shapes as well. • Handles noise. • Handles partial occlusion.

  3. Problem: We process a gray image and create a binary version. Next, we wish to fit lines to the binary image. • from http://www.cs.uregina.ca/Links/class-info/425-nova/Lab4/

  4. More examples • from http://www.cc.utah.edu/~asc10/improc/project4/README.html

  5. Problem: We process a gray image and create a binary version. Next, we wish to fit lines to the binary image. • Slope-intercept equation of line: • where a is the slope (y/  x), and b is the y-intercept

  6. Problem: We process a gray image and create a binary version. Next, we wish to fit lines to the binary image. • Slope-intercept: y=ax+b • We typically think of (x,y) as variables and (a,b) as constants. • Instead, let’s think of (a,b) as variables and (x,y) as constants. Rewritten: b=-xa+y • Note that this is also the equation of a line but in (a,b) space. • We can pass (infinitely) many lines at different angles through (x,y). As we do this, we’ll form a line in (a,b) space.

  7. Passing many lines through an (x,y) point. • Figure by Anne Solberg

  8. Figure by Anne Solberg. • Two points in (x,y)-space define a line. • However (if we pass infinitely many lines through each of these points), we obtain two different lines in (a,b)-space for each of these points.

  9. Figure by Anne Solberg. • Two points in (x,y)-space define a line. • However (if we pass infinitely many lines through each of these points), we obtain two different lines in (a,b)-space for each of these points. • Then line between them in (x,y)-space gives rise to a point of intersection in (a,b)-space.

  10. problem • (a,b)-space can’t be used in practice because vertical lines have infinite slope!

  11. problem • (a,b)-space can’t be used in practice because vertical lines have infinite slope! • Solution: • Use polar coordinates. Lines are then represented by their angle  (from the x-axis) and perpendicular distance from the origin, r. • All points on the same line will have the same (r,). • (figure from http://en.wikipedia.org/wiki/Hough_transform)

  12. note • Each point in (x,y)-space gives rise to a sinusoid in (r,)-space. • But that’s OK. Lines in (x,y)-space will still give rise to intersections in (r,)-space.

  13. Data structure • Use an accumulator matrix (2D histogram; call it A) of counts for (r,). • Voting algorithm. • We’ll get one vote for each point along the sinusoid. • Two votes at points of intersection of sinusoids (which denote lines in (x,y)-space. • More than two votes for multiple co-linear points (in (x,y)-space). • Then the points in (r,)-space with the most votes denote strong lines in (x,y)-space.

  14. Data structure • Use an accumulator matrix (2D histogram; call it A) of counts for (r,). • Voting algorithm. • So we need to quantize the allowable values for r and . • For r, we can use all the integer values from 0 to the largest image diagonal distance. (We could use more as well. For example, we could multiply this value by 10 and get up to a resolution of 10ths.) • For , we can quantize to one degree increments, or we can use the same number as used for r.

  15. algorithm • Let Q be the number of angles into which  was quantized. • For each point, pi in P: • For each qi in Q • Assume that a line at angle =qi passes through pi. • Calculate r for this line • Increment A[r, ]. • The values in A that exceed some threshold (or the K greatest values in A) are the strongest lines. • What is the complexity of this algorithm?

  16. algorithm • Let Q be the number of angles into which  was quantized. • For each point, pi in P: • For each qi in Q • Assume that a line at angle =qi passes through pi. • Calculate r for this line • Increment A[r, ]. • The values in A that exceed some threshold (or the K greatest values in A) are the strongest lines. • What is the complexity of this algorithm? |P|*|Q| • But since Q is a constant that we determine, we can think of it as |P|.

  17. Generalization to other shapes • y = ax + b can be written as ax + b - y = 0. • In general, f(x,a)=0, where x and a are vectors. • Consider the equation of a circle, (x-a)2 + (y-b) 2 = r2. • So our vector x above will be <x,y> and a will be <a,b,r> (3D). • Consider the equation of an ellipse, (x-h) 2/a2 + (y-k) 2/b2 = 1. • In this case, our vector x will again be <x,y> and a will be <h,k,a,b> (4D). • However, this only characterizes ellipses that are aligned with the axes. So in general, for ellipses we need 5D space, <h,k,a,b,>.

  18. More about the accumulator Matrix …

  19. Ex. two points: • (r==10 && c==10) • (r==100 && c==10)

  20. Ex. four points: • (r==75 && c==75) • (r==200 && c==200) • (r==300 && c==300) • (r==500 && c==500)

  21. Let’s take a look at one with gimp. • This test has just two point, (200,200) and (500,500). • We see nothing (at 18% magnification)!

  22. At 100% we can begin to see the sinusoids. • But we are only changing theta by 0.1 so between 0..2 Pi there are only 62 samples. • So the intersections “miss.” • So let’s try more samples.

  23. Let’s try sampling in one degree increments (resulting in 360 samples). • Now we see intersections!

  24. Let’s try sampling in one degree increments (resulting in 360 samples). • Now we see intersections! • And a look at the PGM file confirms that the max value is 2.

  25. Let’s try sampling in one degree increments (resulting in 360 samples). • Now we see intersections! • But there appears to be two! Why?

  26. Let’s try sampling in one degree increments (resulting in 360 samples). • Now we see intersections! • But there appears to be two! Why? • Because we are rotating around 360 when we only need 180.

  27. Better! • But now I’m afraid that I might miss intersections due to undersampling. So let’s sample tenths or hundredths of a degree (instead of one degree increments).

  28. But where are the most votes? • Not at the points of intersection! • Why? • Because many points along the real curve are mapping (repeatedly) so a single point in our array.

  29. Solution(S)? • (Oversample.) As you trace along a sinusoid, keep track of the last point and don’t count repetitions. • easier to code • less reliable • (Undersample.) As you trace along a sinusoid, draw straight lines between pairs of points (and still disallowing repeats as in #1). • harder to code • more reliable

  30. Moral of the story: Sometimes it’s better to play “connect the dots” than it is to oversample!

More Related