Theory[edit]
In automated analysis of digital images, a subproblem often arises of detecting simple shapes, such as straight lines, circles or ellipses. In many cases an edge detector can be used as a pre-processing stage to obtain image points or image pixels that are on the desired curve in the image space. Due to imperfections in either the image data or the edge detector, however, there may be missing points or pixels on the desired curves as well as spatial deviations between the ideal line/circle/ellipse and the noisy edge points as they are obtained from the edge detector. For these reasons, it is often non-trivial to group the extracted edge features to an appropriate set of lines, circles or ellipses. The purpose of the Hough transform is to address this problem by making it possible to perform groupings of edge points into object candidates by performing an explicit voting procedure over a set of parameterized image objects (Shapiro and Stockman, 304).
The simplest case of Hough transform is the linear transform for detecting straight lines. In the image space, the straight line can be described as y = mx + b where the parameter m is the slope of the line, and b is the intercept (y-intercept). This is called the slope-intercept model of a straight line. In the Hough transform, a main idea is to consider the characteristics of the straight line not as discrete image points (x1, y1), (x2, y2), etc., but instead, in terms of its parameters according to the slope-intercept model, i.e., the slope parameter m and the intercept parameter b. In general, the straight line y = mx + b can be represented as a point (b, m) in the parameter space. However, vertical lines pose a problem. They are more naturally described as x = a and would give rise to unbounded values of the slope parameter m. Thus, for computational reasons, Duda and Hart proposed the use of a different pair of parameters, denoted and
(theta), for the lines in the Hough transform. These two values, taken in conjunction, define a polar coordinate.
The parameter represents the algebraic distance between the line and the origin, while
is the angle of the vector orthogonal to the line and pointing toward the half upper plane (see Coordinates). If the line is located above the origin,
is simply the angle of the vector from the origin to this closest point. Using this parameterization, the equation of the line can be written as[5]
which can be rearranged to (Shapiro and Stockman, 304).
It is therefore possible to associate with each line of the image a pair (r,θ) which is unique if and
, or if
and
. The (r,θ) plane is sometimes referred to as Hough space for the set of straight lines in two dimensions. This representation makes the Hough transform conceptually very close to the two-dimensional Radon transform. (They can be seen as different ways of looking at the same transform.[6])
For an arbitrary point on the image plane with coordinates, e.g., (x0, y0), the lines that go through it are the pairs (r,θ) with
,
where (the algebraic distance between the line and the origin) is determined by
.
If is required to be positive, then
must vary in
. In other words,
is the angle of the vector from the origin and this closest point (if
), or the angle of the vector orthogonal to the line and pointing to the half upper plane (if
). The lines that go through (x0, y0) are then
.
These representations correspond to a sinusoidal curve in the (r,θ) plane, which is unique to that point. If the curves corresponding to two points are superimposed, the location (in the Hough space) where they cross corresponds to a line (in the original image space) that passes through both points. More generally, a set of points that form a straight line will produce sinusoids which cross at the parameters for that line. Thus, the problem of detecting collinear points can be converted to the problem of finding concurrent curves.[7]
Example[edit]
Consider three data points, shown here as black dots.
- For each data point, a number of lines are plotted going through it, all at different angles. These are shown here as solid lines.
- For each solid line a line is plotted which is perpendicular to it and which intersects the origin. These are shown as dashed lines.
- The length (i.e. perpendicular distance to the origin) and angle of each dashed line is measured. In the diagram above, the results are shown in tables.
- This is repeated for each data point.
- A graph of the line lengths for each angle, known as a Hough space graph, is then created.
The point where the curves intersect gives a distance and angle. This distance and angle indicate the line which intersects the points being tested. In the graph shown the lines intersect at the pink point; this corresponds to the solid pink line in the diagrams above, which passes through all three points.
The following is a different example showing the results of a Hough transform on a raster image containing two thick lines.
The results of this transform were stored in a matrix. Cell value represents the number of curves through any point. Higher cell values are rendered brighter. The two distinctly bright spots are the Hough parameters of the two lines. From these spots' positions, angle and distance from image center of the two lines in the input image can be determined.