Presentation is loading. Please wait.

Presentation is loading. Please wait.

HOUGH TRANSFORM. Introduced in 1962 by Paul Hough pronounced like “tough” according to orm.html.

Similar presentations


Presentation on theme: "HOUGH TRANSFORM. Introduced in 1962 by Paul Hough pronounced like “tough” according to orm.html."— Presentation transcript:

1 HOUGH TRANSFORM

2 Introduced in 1962 by Paul Hough pronounced like “tough” according to http://www.citidel.org/bitstream/10117/1289/1/HoughTransf orm.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/R EADME.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, p i in P: For each q i in Q Assume that a line at angle  =q i passes through p i. 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, p i in P: For each q i in Q Assume that a line at angle  =q i passes through p i. 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. 1.Consider the equation of a circle, (x-a) 2 + (y-b) 2 = r 2. So our vector x above will be and a will be (3D). 1.Consider the equation of an ellipse, (x-h) 2 /a 2 + (y-k) 2 /b 2 = 1. In this case, our vector x will again be and a will be (4D). However, this only characterizes ellipses that are aligned with the axes. So in general, for ellipses we need 5D space,.

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

29 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.

30 SOLUTION(S)? 1.(Oversample.) As you trace along a sinusoid, keep track of the last point and don’t count repetitions. easier to code less reliable 2.(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

31 MORAL OF THE STORY: SOMETIMES IT’S BETTER TO PLAY “CONNECT THE DOTS” THAN IT IS TO OVERSAMPLE!


Download ppt "HOUGH TRANSFORM. Introduced in 1962 by Paul Hough pronounced like “tough” according to orm.html."

Similar presentations


Ads by Google