mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-25 13:30:51 +08:00
Merge pull request #475 from sciunto/docstring
Various docstring corrections + fix an example
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
# vim ft=yaml
|
||||
# travis-ci.org definition for skimage build
|
||||
#
|
||||
# We pretend to be erlang because we need can't use the python support in
|
||||
# We pretend to be erlang because we can't use the python support in
|
||||
# travis-ci; it uses virtualenvs, they do not have numpy, scipy, matplotlib,
|
||||
# and it is impractical to build them
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ References
|
||||
|
||||
'''
|
||||
|
||||
from skimage.transform import hough, hough_peaks, probabilistic_hough
|
||||
from skimage.transform import hough_line, hough_peaks, probabilistic_hough
|
||||
from skimage.filter import canny
|
||||
from skimage import data
|
||||
|
||||
@@ -77,7 +77,7 @@ idx = np.arange(25, 75)
|
||||
image[idx[::-1], idx] = 255
|
||||
image[idx, idx] = 255
|
||||
|
||||
h, theta, d = hough(image)
|
||||
h, theta, d = hough_line(image)
|
||||
|
||||
plt.figure(figsize=(8, 4))
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage.transform import hough
|
||||
from skimage.transform import hough_line
|
||||
|
||||
img = np.zeros((100, 150), dtype=bool)
|
||||
img[30, :] = 1
|
||||
@@ -11,7 +11,7 @@ for i in range(90):
|
||||
img[i, i] = 1
|
||||
img += np.random.random(img.shape) > 0.95
|
||||
|
||||
out, angles, d = hough(img)
|
||||
out, angles, d = hough_line(img)
|
||||
|
||||
plt.subplot(1, 2, 1)
|
||||
|
||||
@@ -20,8 +20,8 @@ plt.title('Input image')
|
||||
|
||||
plt.subplot(1, 2, 2)
|
||||
plt.imshow(out, cmap=plt.cm.bone,
|
||||
extent=(d[0], d[-1],
|
||||
np.rad2deg(angles[0]), np.rad2deg(angles[-1])))
|
||||
extent=(np.rad2deg(angles[0]), np.rad2deg(angles[-1]),
|
||||
d[0], d[-1]))
|
||||
plt.title('Hough transform')
|
||||
plt.xlabel('Angle (degree)')
|
||||
plt.ylabel('Distance (pixel)')
|
||||
|
||||
@@ -293,12 +293,12 @@ def ellipse_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t yradius,
|
||||
cy, cx : int
|
||||
Centre coordinate of ellipse.
|
||||
yradius, xradius: int
|
||||
Main radial values.
|
||||
Minor and major semi-axes. ``(x/xradius)**2 + (y/yradius)**2 = 1``.
|
||||
|
||||
Returns
|
||||
-------
|
||||
rr, cc : (N,) ndarray of int
|
||||
Indices of pixels that belong to the circle perimeter.
|
||||
Indices of pixels that belong to the ellipse perimeter.
|
||||
May be used to directly index into an array, e.g.
|
||||
``img[rr, cc] = 1``.
|
||||
|
||||
|
||||
@@ -124,6 +124,12 @@ def hough_line(img, theta=None):
|
||||
distances : ndarray
|
||||
Distance values.
|
||||
|
||||
Notes
|
||||
-----
|
||||
The origin is the top left corner of the original image.
|
||||
The angle is counted clockwise from 9 o'clock.
|
||||
The distance is the minimal algebraic distance from this origin to the line.
|
||||
|
||||
Examples
|
||||
--------
|
||||
Generate a test image:
|
||||
@@ -138,7 +144,7 @@ def hough_line(img, theta=None):
|
||||
|
||||
Apply the Hough transform:
|
||||
|
||||
>>> out, angles, d = hough(img)
|
||||
>>> out, angles, d = hough_line(img)
|
||||
|
||||
.. plot:: hough_tf.py
|
||||
|
||||
@@ -178,12 +184,12 @@ def hough_peaks(hspace, angles, dists, min_distance=10, min_angle=10,
|
||||
Parameters
|
||||
----------
|
||||
hspace : (N, M) array
|
||||
Hough space returned by the `hough` function.
|
||||
Hough space returned by the `hough_line` function.
|
||||
angles : (M,) array
|
||||
Angles returned by the `hough` function. Assumed to be continuous
|
||||
Angles returned by the `hough_line` function. Assumed to be continuous
|
||||
(`angles[-1] - angles[0] == PI`).
|
||||
dists : (N, ) array
|
||||
Distances returned by the `hough` function.
|
||||
Distances returned by the `hough_line` function.
|
||||
min_distance : int
|
||||
Minimum distance separating lines (maximum filter size for first
|
||||
dimension of hough space).
|
||||
@@ -204,14 +210,14 @@ def hough_peaks(hspace, angles, dists, min_distance=10, min_angle=10,
|
||||
Examples
|
||||
--------
|
||||
>>> import numpy as np
|
||||
>>> from skimage.transform import hough, hough_peaks
|
||||
>>> from skimage.transform import hough_line, hough_peaks
|
||||
>>> from skimage.draw import line
|
||||
>>> img = np.zeros((15, 15), dtype=np.bool_)
|
||||
>>> rr, cc = line(0, 0, 14, 14)
|
||||
>>> img[rr, cc] = 1
|
||||
>>> rr, cc = line(0, 14, 14, 0)
|
||||
>>> img[cc, rr] = 1
|
||||
>>> hspace, angles, dists = hough(img)
|
||||
>>> hspace, angles, dists = hough_line(img)
|
||||
>>> hspace, angles, dists = hough_peaks(hspace, angles, dists)
|
||||
>>> angles
|
||||
array([ 0.74590887, -0.79856126])
|
||||
|
||||
Reference in New Issue
Block a user