Line detection consists of detecting alignments of points in an image of contours. The usual method for line detection is the Hough transform [Hough 1962]. Like the Fourier transform, it transposes the image from the spatial space to another space, where the information of interest is represented differently: the lines in the spatial space are transformed into points in the Hough space.
First parameterization¶
In the spatial space , a line is parameterized by its coefficients and , giving the equation . Thus, any line can be identified by the pair . This is Hough’s idea: each line of the image can be represented by a point in the Hough space .
Figure 1:The Hough transform transforms a line in the image into a point in the parameter space.
The Hough space is called the “parameter space”. On a computer, the parameter space is finite and discretized and is called the “accumulator”.
In the same way, a point in the image is represented by a line in the parameter space.
In particular, a constant line in the parameter space corresponds to a point of abscissa in the image.
If several points in the image are aligned, their respective lines in the parameter space intersect at a single point, which defines the equation of the line connecting them.
But the parameterization has a major drawback: a vertical line of slope cannot be represented. So another parameterization needs to be used in practice.
New parameterization¶
To avoid the aforementioned problem of the parameterization space , the lines are defined from two other parameters:
the distance of the segment connecting the origin with the point closest to the line (this segment is perpendicular to the line),
the angle of this segment with the x-axis.
Each line of the image is therefore parameterized by the pair which corresponds to a point in the parameter space .
Figure 5:New parameterization of the Hough transform.
We can show that for each point of the image, a sinusoid of equation is associated in the space . The sinusoids corresponding to the points of the same line intersect at a unique point in the parameter space. This parameterization allows to model any type of traight line.
Hough transform for line detection¶
The Hough transform algorithm is as follows:
The Hough transform applies on a binary (black and white) image with lines on a background. Alternatively, if you search for straight borders in the image, you must first compute an Edge detection of the image.
For example, consider the problem of searching for the borders on the diamond in Figure 7: an edge detection is first applied on the image, then the accumulator of the Hough transform shows four bright spots, corresponding to the four edges of the shape.
Figure 7:Hough transform associated with the image on the left. The sinusoids intersect at four (very bright) points, each one is associated with the line with the same letter. In particular, A is a line at distance 50 from the origin and its normal make a angle of 45°.
Figure 8 gives an example of a Hough transform on a real photograph.
Figure 8:Hough transform applied on a real image. The green circles identify the three brighter points in the accumulator.
Besides, it appears that the Hough transform is robust to noise and to occultation (it can detect partially covered objects)
Hough transform for other shapes¶
The Hough transform is not restricted to lines and can be used to detect any shape that has a mathematical parameterization: circles, ellipses, etc.
To detect other parametrized objectif with Hough transform, the parameter space has to be adapted to the mathematical parameterization. For example, a circle is parameterized by three parameters (the center coordinates and the radius), then the corresponding Hough space is three-dimensional.
In consequence, as the dimension of the accumulator is equal to the number of parameters, the main drawback of this method is that the computing time and the memory used quickly become significant for some shapes.