mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 21:04:47 +08:00
Shorter hough_circle example
This commit is contained in:
@@ -152,22 +152,14 @@ def hough_circle(image, radius, normalize=True, full_output=False):
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.transform import hough_circle
|
||||
>>> from skimage.draw import circle_perimeter
|
||||
>>> img = np.zeros((100, 100), dtype=np.bool_)
|
||||
>>> X, Y = np.meshgrid(np.arange(100), np.arange(100))
|
||||
>>> x0, y0, radius = 20, 35, 23
|
||||
>>> circle = np.abs((X-x0)**2+(Y-y0)**2-radius**2)<5**2
|
||||
>>> img[circle] = 1
|
||||
>>> # Find position of circle from known radius:
|
||||
>>> res = hough_circle(img, np.array([radius]))[0, :, :]
|
||||
>>> y, x = np.unravel_index(np.argmax(res), res.shape)
|
||||
>>> x, y
|
||||
(20, 35)
|
||||
>>> # Find position and radius by trying a range of radii:
|
||||
>>> radii_range = np.arange(5, 50)
|
||||
>>> res = hough_circle(img, radii_range)
|
||||
>>> ridx, y, x = np.unravel_index(np.argmax(res), res.shape)
|
||||
>>> x, y, radii_range[ridx]
|
||||
(20, 35, 23)
|
||||
>>> rr, cc = circle_perimeter(25, 35, 23)
|
||||
>>> img[rr, cc] = 1
|
||||
>>> try_radii = np.arange(5, 50)
|
||||
>>> res = hough_circle(img, try_radii)
|
||||
>>> ridx, r, c = np.unravel_index(np.argmax(res), res.shape)
|
||||
(25, 35, 23)
|
||||
|
||||
"""
|
||||
return _hough_circle(image, radius.astype(np.intp),
|
||||
|
||||
Reference in New Issue
Block a user