polygon_perimeter
-
skimage.draw.polygon_perimeter(cr, cc, shape=None, clip=False)
[source] -
Generate polygon perimeter coordinates.
Parameters: cr : (N,) ndarray
Row (Y) coordinates of vertices of polygon.
cc : (N,) ndarray
Column (X) coordinates of vertices of polygon.
shape : tuple, optional
Image shape which is used to determine maximum extents of output pixel coordinates. This is useful for polygons which exceed the image size. By default the full extents of the polygon are used.
clip : bool, optional
Whether to clip the polygon to the provided shape. If this is set to True, the drawn figure will always be a closed polygon with all edges visible.
Returns: pr, pc : ndarray of int
Pixel coordinates of polygon. May be used to directly index into an array, e.g.
img[pr, pc] = 1
.Examples
>>> from skimage.draw import polygon_perimeter >>> img = np.zeros((10, 10), dtype=np.uint8) >>> rr, cc = polygon_perimeter([5, -1, 5, 10], ... [-1, 5, 11, 5], ... shape=img.shape, clip=True) >>> img[rr, cc] = 1 >>> img array([[0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0]], dtype=uint8)
Please login to continue.