line

line

skimage.draw.line()

Generate line pixel coordinates.

Parameters:

y0, x0 : int

Starting position (row, column).

y1, x1 : int

End position (row, column).

Returns:

rr, cc : (N,) ndarray of int

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

See also

line_aa
Anti-aliased line generator

Examples

>>> from skimage.draw import line
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc = line(1, 1, 8, 8)
>>> img[rr, cc] = 1
>>> img
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
doc_scikit_image
2017-01-12 17:21:47
Comments
Leave a Comment

Please login to continue.