Presentation is loading. Please wait.

Presentation is loading. Please wait.

October 16, 2014Computer Vision Lecture 12: Image Segmentation II 1 Hough Transform The Hough transform is a very general technique for feature detection.

Similar presentations


Presentation on theme: "October 16, 2014Computer Vision Lecture 12: Image Segmentation II 1 Hough Transform The Hough transform is a very general technique for feature detection."— Presentation transcript:

1 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 1 Hough Transform The Hough transform is a very general technique for feature detection. In the present context, we will use it for the detection of straight lines as contour descriptors in edge point arrays. We could use other variants of the Hough transform to detect circular and other shapes. We could even use it outside of computer vision, for example in data mining applications. So understanding the Hough transform may benefit you in many situations.

2 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 2 Hough Transform The Hough transform is a voting mechanism. In general, each point in the input space votes for several combinations of parameters in the output space. Those combinations of parameters that receive the most votes are declared the winners. We will use the Hough transform to fit a straight line to edge position data. To keep the description simple and consistent, let us assume that the input image is continuous and described by an x-y coordinate system.

3 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 3 Hough Transform A straight line can be described by the equation: y = mx + c The variables x and y are the parameters of our input space, and m and c are the parameters of the output space. For a given value (x, y) indicating the position of an edge in the input, we can determine the possible values of m and c by rewriting the above equation: c = -xm + y You see that this represents a straight line in m-c space, which is our output space.

4 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 4 Hough Transform Example: Each of the three points A, B, and C on a straight line in input space are transformed into straight lines in output space. A B C A B C 0x y input space 0m c output space The parameters of their crossing point (which would be the winners) are the parameters of the straight line in input space. winner parameters

5 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 5 Hough Transform Hough Transform Algorithm: 1.Quantize input and output spaces appropriately. 2.Assume that each cell in the parameter (output) space is an accumulator (counter). Initialize all cells to zero. 3.For each point (x, y) in the image (input) space, increment by one each of the accumulators that satisfy the equation. 4.Maxima in the accumulator array correspond to the parameters of model instances.

6 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 6 Hough Transform The Hough transform does not require preprocessing of edge information such as ordering, noise removal, or filling of gaps. It simply provides an estimate of how to best fit a straight line (or other curve model) to the available edge data. If there are multiple straight lines in the image, the Hough transform will result in multiple peaks. You can search for these peaks to find the parameters for all the corresponding straight lines.

7 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 7 Improved Hough Transform Here is some practical advice for doing the Hough transform (e.g., for some future assignment). The m-c space described on the previous slides is simple but not very practical. It cannot represent vertical lines, and the closer the orientation of a line gets to being vertical, the greater is the change in m required to turn the line significantly. We are going to discuss an alternative output space that requires a bit more computation but avoids the problems of the m-c space.

8 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 8 Improved Hough Transform As we said before, it is problematic to use m (slope) and c (intercept) as an output space. Instead, it is a good idea to use the orientation  and length d of the normal of a straight line to describe it. The normal n of a straight line l is perpendicular to l and connects l with the origin of the coordinate system. The range of  is from 0  to 360 , and the range of d is from 0 to the length of the image diagonal. Note that we can skip the  interval from 180  to 270 , because it would require a negative d. Let us assume that the image is 450×450 units large.

9 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 9 Improved Hough Transform The parameters  and d form the output space for our Hough transform. line to be described  d input space 0450 Row i Column j 4500 representation of same line in output space 0000 360  636 output space  d 0

10 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 10 Improved Hough Transform For any edge point (i 0, j 0 ) indicated by our Sobel edge detector, we have to find all parameters  and d for those straight lines that pass through (i 0, j 0 ). We will then increase the counters in our output space located at every ( , d) by the edge strength, i.e., the magnitude provided by the Sobel detector. This way we will find out which parameters ( , d) are most likely to indicate the clearest lines in the image. But first of all, we have to discuss how to find all the parameters ( , d) for a given point (i 0, j 0 ).

11 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 11 Improved Hough Transform But how can we compute parameter d for each value of  ? Idea: Rotate (i 0, j 0 ) around origin by -  so that it lands on i-axis. Then the i-coordinate of the rotated point is the value of d. 1111 d1d1d1d1 2222 d2d2d2d2 (i 0, j 0 ) 3333 d3d3d3d3 0 450 Column j Row i 450 0 By varying  from 0 to 360 we can find all lines crossing (i 0, j 0 ):

12 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 12 Improved Hough Transform And how do we rotate a point in two-dimensional space? The simplest way is to multiply the point vector with a rotation matrix. We compute the rotated point (i R, j R ) as obtained by rotation of point (i 0, j 0 ) around the point (0, 0) by the angle  as follows:

13 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 13 Improved Hough Transform We are only interested in the i-coordinate: i R = i 0  cos  - j 0  sin  In our case, we want to rotate by the angle -  : i R = i 0  cos(-  ) - j 0  sin(-  ) i R = i 0  cos  + j 0  sin  Now we can compute parameter d as a function of i 0, j 0, and  : d(i 0, j 0 ;  ) = i 0  cos  + j 0  sin  By varying  we are now able to determine all parameters ( , d) for a given point (i 0, j 0 ) and increase the counters in output space accordingly.

14 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 14 Improved Hough Transform We can then define the straight line representing the “winner” in parametric form using a parameter p. The points (i, j) of the line are then given by the following equation: By varying p within an appropriate range, we can compute every pixel of our straight line. But how can we find the vector (  i,  j) that determines the slope of the line?

15 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 15 Improved Hough Transform The idea here is that the orientation of the straight line is perpendicular to its normal. Since the orientation of the normal is given by the angle , the orientation of the straight line must be given by  - 90 . Therefore, we get:

16 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 16 Improved Hough Transform Then the complete equation for the straight line with parameters ( , d) looks like this: Just vary parameter p in steps of 1 (to catch every pixel) between approximately -900 to 900 (twice the image size). Whenever (i, j) is within the image range, then visualize that pixel in the bitmap.

17 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 17 Sample Results Input Image

18 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 18 Sample Results Edges in input image (Sobel filter output)

19 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 19 Sample Results Hough-transformed edge image  -90  0  0  90  90  180  d

20 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 20 Sample Results Five greatest maxima in Hough-transformed image  270  0  0  90  90  180  d

21 October 16, 2014Computer Vision Lecture 12: Image Segmentation II 21 Sample Results Lines in input image corresponding to Hough maxima


Download ppt "October 16, 2014Computer Vision Lecture 12: Image Segmentation II 1 Hough Transform The Hough transform is a very general technique for feature detection."

Similar presentations


Ads by Google