bezier-curve

bezier_curve

skimage.draw.bezier_curve()

Generate Bezier curve coordinates.

Parameters:

y0, x0 : int

Coordinates of the first control point.

y1, x1 : int

Coordinates of the middle control point.

y2, x2 : int

Coordinates of the last control point.

weight : double

Middle control point weight, it describes the line tension.

shape : tuple, optional

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

Returns:

rr, cc : (N,) ndarray of int

Indices of pixels that belong to the Bezier curve. May be used to directly index into an array, e.g. img[rr, cc] = 1.

Notes

The algorithm is the rational quadratic algorithm presented in reference [R67].

References

[R67] (1, 2) A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf

Examples

>>> import numpy as np
>>> from skimage.draw import bezier_curve
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = bezier_curve(1, 5, 5, -2, 8, 8, 2)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
doc_scikit_image
2017-01-12 17:20:16
Comments
Leave a Comment

Please login to continue.