(I) Straight line article
How is the 1 line represented?
For a straight line in the plane, in the Cartesian coordinate system, there are some common oblique, two-point two methods of representation. In the Hough transformation, however, another representation is considered: use (R,theta) to represent a straight line. where R is the distance from the line to the origin, Theta is the angle between the perpendicular of the line and the x-axis. As shown in.
2 If there are multiple points in the coordinate system, how do you recognize which points are in a straight line?
The idea of using the Hough transform to detect straight lines is to assume N-direction lines for each point, usually n=180, at which point the angular accuracy of the detected line is 1°, and the (r,theta) coordinates of the n-line are computed separately, resulting in n coordinate points. If the points to be judged total N, the resulting (r,theta) coordinates are n*n. For this n*n (r,theta) coordinate, where Theta is a discrete angle, a total of 180 values are taken.
The most important place to come, if more than one point in a straight line, then must have these points in theta= some value theta_i, these points of r approximately equal to R_i. This means that the dots are on a straight line (r_i,theta_i).
3 Take an example to illustrate the following:If there are 3 points in the space, how can you tell if the three points are not in a straight line, and if so, where is the line? In this example, the coordinates of the (R,theta) of the 6 straight lines of the point are obtained for each point, and the 3*6 (r,theta) coordinate is found. It can be found that at THETA=60, the three-point R is approximately 80.7, thus determining that the three points are on a straight line (80.7,60).
This relationship can be more visually represented by the R0theta coordinate system, such as the three-point (R,theta) curve in the figure, which is a straight line passing through these three points at the same time.
In the actual line detection situation, if more than a certain number of points have the same (r,theta) coordinates, then you can decide there is a line here. In the R0theta coordinate system diagram, the apparent junction marks a detected line.
For example, it can be determined that the points on the plane make up two straight lines, that is, two straight lines are detected.
4 Code:In MATLAB provides the Hough transform code, has the Hough,houghlines,houghpeaks, the concrete use can find in the help.
(II) round article
After using the Hough transform to detect the straight line, the method of detecting circle is put forward along with the idea of coordinate transformation.
1 How to represent a circle?
Similar to using (R,theta) to represent a line, use (A,B,R) to determine a circle with a radius of R (a, b).
2 How do i show all the circles at a certain point?
A circle over Point (x1,y1), there is: (X1-A1) ^2 + (Y1-B1) ^2 = r1^2.
Then all the circles of the dot (x1,y1) can be expressed as (A1 (i), B1 (i), R1 (i)), where r1∈ (0, Infinity), each I value corresponds to a different circle, (A1 (i), B1 (i), R1 (i)) represents an infinite number of points (x1,y1) of the circle.
3 How do I determine that multiple points are on the same circle?
As stated in (2), all circles of the over point (X1,Y1) can be expressed as (A1 (i), B1 (i), R1 (i)), and all circles over points (x2,y2) can be represented as (A2 (i), B2 (i), R2 (i)), and all circles over points (x3,y3) can be expressed as (A3 (i), B3 (i), R3 (i)), if these three points are on the same circle, then there is a value (A0,B0,R0), which makes a0 = A1 (k) =a2 (k) =a3 (k) and B0 = B1 (k) =b2 (k) =b3 (k) and r0 = R1 (k) =r2 (k) =r3 (k), That is, these three points are at the same time on a circle (A0,B0,R0).
Can be seen from the image:
First, all the circles (x1,y1) are analyzed (A1 (i), B1 (i), R1 (i)), and when the R1 (i) is determined, the trajectory (A1 (i), B1 (i)) is a circle (X1,Y1,R1 (i)) with a center radius of R1 (i). Then, all the circles (A1 (i), B1 (i), R1 (i)) consist of a conical face with a vertex (x1,y1,0) and a cone angle of 90 degrees.
Intersection A of three conical faces is a circle that crosses these three points simultaneously.
4 How do I use code to implement the process of detecting a circle?
Although the above analysis is very simple, but in the code to achieve the trouble, first over each point of (a (i), B (i), R (i)) have an infinite number of points to be detected, to 22 comparison of all (A,b,r) value is a huge amount of computation.
...... To be Continued ... Transferred from: http://blog.163.com/yuyang_tech/blog/static/21605008320130233343990/
How does the Hough transform detect lines and circles?