Fix inconsistencies in examples and many more improvements

This commit is contained in:
Johannes Schönberger
2013-04-27 16:47:33 +02:00
parent 41007b417b
commit d0ee6ade61
40 changed files with 138 additions and 132 deletions
+31 -34
View File
@@ -1,50 +1,47 @@
'''
"""
===============
Hough transform
===============
The Hough transform in its simplest form is a `method to detect
straight lines <http://en.wikipedia.org/wiki/Hough_transform>`__.
The Hough transform in its simplest form is a `method to detect straight lines
<http://en.wikipedia.org/wiki/Hough_transform>`__.
In the following example, we construct an image with a line
intersection. We then use the Hough transform to explore a parameter
space for straight lines that may run through the image.
In the following example, we construct an image with a line intersection. We
then use the Hough transform to explore a parameter space for straight lines
that may run through the image.
Algorithm overview
------------------
Usually, lines are parameterised as :math:`y = mx + c`, with a
gradient :math:`m` and y-intercept `c`. However, this would mean that
:math:`m` goes to infinity for vertical lines. Instead, we therefore
construct a segment perpendicular to the line, leading to the origin.
The line is represented by the length of that segment, :math:`r`, and
the angle it makes with the x-axis, :math:`\theta`.
Usually, lines are parameterised as :math:`y = mx + c`, with a gradient
:math:`m` and y-intercept `c`. However, this would mean that :math:`m` goes to
infinity for vertical lines. Instead, we therefore construct a segment
perpendicular to the line, leading to the origin. The line is represented by the
length of that segment, :math:`r`, and the angle it makes with the x-axis,
:math:`\theta`.
The Hough transform constructs a histogram array representing the
parameter space (i.e., an :math:`M \times N` matrix, for :math:`M`
different values of the radius and :math:`N` different values of
:math:`\theta`). For each parameter combination, :math:`r` and
:math:`\theta`, we then find the number of non-zero pixels in the
input image that would fall close to the corresponding line, and
The Hough transform constructs a histogram array representing the parameter
space (i.e., an :math:`M \times N` matrix, for :math:`M` different values of the
radius and :math:`N` different values of :math:`\theta`). For each parameter
combination, :math:`r` and :math:`\theta`, we then find the number of non-zero
pixels in the input image that would fall close to the corresponding line, and
increment the array at position :math:`(r, \theta)` appropriately.
We can think of each non-zero pixel "voting" for potential line
candidates. The local maxima in the resulting histogram indicates the
parameters of the most probably lines. In our example, the maxima
occur at 45 and 135 degrees, corresponding to the normal vector
angles of each line.
We can think of each non-zero pixel "voting" for potential line candidates. The
local maxima in the resulting histogram indicates the parameters of the most
probably lines. In our example, the maxima occur at 45 and 135 degrees,
corresponding to the normal vector angles of each line.
Another approach is the Progressive Probabilistic Hough Transform
[1]_. It is based on the assumption that using a random subset of
voting points give a good approximation to the actual result, and that
lines can be extracted during the voting process by walking along
connected components. This returns the beginning and end of each
line segment, which is useful.
Another approach is the Progressive Probabilistic Hough Transform [1]_. It is
based on the assumption that using a random subset of voting points give a good
approximation to the actual result, and that lines can be extracted during the
voting process by walking along connected components. This returns the beginning
and end of each line segment, which is useful.
The function `probabilistic_hough` has three parameters: a general
threshold that is applied to the Hough accumulator, a minimum line
length and the line gap that influences line merging. In the example
below, we find lines longer than 10 with a gap less than 3 pixels.
The function `probabilistic_hough` has three parameters: a general threshold
that is applied to the Hough accumulator, a minimum line length and the line gap
that influences line merging. In the example below, we find lines longer than 10
with a gap less than 3 pixels.
References
----------
@@ -57,7 +54,7 @@ References
Detect Lines and Curves in Pictures," Comm. ACM, Vol. 15,
pp. 11-15 (January, 1972)
'''
"""
from skimage.transform import (hough_line, hough_line_peaks,
probabilistic_hough_line)