bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / draw / draw / rectangle_perimeter
function
skimage.draw.draw:rectangle_perimeter
source: /dev/scikit-image/src/skimage/draw/draw.py :869
Signature
def rectangle_perimeter ( start , end = None , extent = None , shape = None , clip = False ) Summary
Generate coordinates of pixels that are exactly around a rectangle.
Parameters
start: tupleOrigin point of the inner rectangle, e.g.,
(row, column).end: tupleEnd point of the inner rectangle
(row, column). For a 2D matrix, the slice defined by inner the rectangle is[start:(end+1)]. Eitherendorextentmust be specified.extent: tupleThe extent (size) of the inner rectangle. E.g.,
(num_rows, num_cols). Eitherendorextentmust be specified. Negative extents are permitted. Seerectangleto better understand how they behave.shape: tuple, optionalImage 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.
clip: bool, optionalWhether 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.
Returns
coords: array of int, shape (2, Npoints)The coordinates of all pixels in the rectangle.
Examples
import numpy as np 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✓
img = np.zeros((5, 5), dtype=np.uint8) r, c = rectangle_perimeter(start, (10, 10), shape=img.shape, clip=True) img[r, c] = 1 img✓
Aliases
-
skimage.draw.rectangle_perimeter