rectangle_perimeter(start, end=None, extent=None, shape=None, clip=False)
Origin point of the inner rectangle, e.g., (row, column)
.
End point of the inner rectangle (row, column)
. For a 2D matrix, the slice defined by inner the rectangle is [start:(end+1)]
. Either end
or :None:None:`extent`
must be specified.
The extent (size) of the inner rectangle. E.g., (num_rows, num_cols)
. Either end
or :None:None:`extent`
must be specified. Negative extents are permitted. See rectangle
to better understand how they behave.
Image shape used to determine the maximum bounds of the output coordinates. This is useful for clipping perimeters that exceed the image size. By default, no clipping is done. Must be at least length 2. Only the first two values are used to determine the extent of the input image.
Whether to clip the perimeter to the provided shape. If this is set to True, the drawn figure will always be a closed polygon with all edges visible.
The coordinates of all pixels in the rectangle.
Generate coordinates of pixels that are exactly around a rectangle.
>>> import numpy as npThis example is valid syntax, but we were not able to check execution
... from skimage.draw import rectangle_perimeter
... img = np.zeros((5, 6), dtype=np.uint8)
... start = (2, 3)
... end = (3, 4)
... rr, cc = rectangle_perimeter(start, end=end, shape=img.shape)
... img[rr, cc] = 1
... img array([[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1]], dtype=uint8)
>>> img = np.zeros((5, 5), dtype=np.uint8)See :
... r, c = rectangle_perimeter(start, (10, 10), shape=img.shape, clip=True)
... img[r, c] = 1
... img array([[0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [0, 0, 1, 0, 1], [0, 0, 1, 1, 1]], dtype=uint8)
The following pages refer to to this document either explicitly or contain code examples using this.
skimage.draw.draw.rectangle_perimeter
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them