ellipse

ellipse

skimage.draw.ellipse(r, c, yradius, xradius, shape=None) [source]

Generate coordinates of pixels within ellipse.

Parameters:

r, c : double

Centre coordinate of ellipse.

yradius, xradius : double

Minor and major semi-axes. (x/xradius)**2 + (y/yradius)**2 = 1.

shape : tuple, optional

Image shape which is used to determine the maximum extent of output pixel coordinates. This is useful for ellipses which exceed the image size. By default the full extent of the ellipse are used.

Returns:

rr, cc : ndarray of int

Pixel coordinates of ellipse. May be used to directly index into an array, e.g. img[rr, cc] = 1.

Examples

>>> from skimage.draw import ellipse
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = ellipse(5, 5, 3, 4)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
doc_scikit_image
2017-01-12 17:20:50
Comments
Leave a Comment

Please login to continue.