mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-19 12:40:22 +08:00
[ENH] Fixed some PEP8 issues in example gallery.
This commit is contained in:
@@ -16,16 +16,16 @@ 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,
|
||||
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
|
||||
increment the array at position :math:`(r, \theta)` appropriately.
|
||||
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
|
||||
@@ -35,13 +35,13 @@ 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.
|
||||
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.
|
||||
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
|
||||
----------
|
||||
@@ -84,9 +84,9 @@ ax[0].set_title('Input image')
|
||||
ax[0].axis('image')
|
||||
|
||||
ax[1].imshow(np.log(1 + h),
|
||||
extent=[np.rad2deg(theta[-1]), np.rad2deg(theta[0]),
|
||||
d[-1], d[0]],
|
||||
cmap=plt.cm.gray, aspect=1/1.5)
|
||||
extent=[np.rad2deg(theta[-1]), np.rad2deg(theta[0]),
|
||||
d[-1], d[0]],
|
||||
cmap=plt.cm.gray, aspect=1/1.5)
|
||||
ax[1].set_title('Hough transform')
|
||||
ax[1].set_xlabel('Angles (degrees)')
|
||||
ax[1].set_ylabel('Distance (pixels)')
|
||||
@@ -106,7 +106,8 @@ ax[2].axis('image')
|
||||
|
||||
image = data.camera()
|
||||
edges = canny(image, 2, 1, 25)
|
||||
lines = probabilistic_hough_line(edges, threshold=10, line_length=5, line_gap=3)
|
||||
lines = probabilistic_hough_line(edges, threshold=10, line_length=5,
|
||||
line_gap=3)
|
||||
|
||||
fig2, ax = plt.subplots(1, 3, figsize=(8, 3))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user