Module: draw

skimage.draw.bresenham Generate line pixel coordinates.
skimage.draw.circle Generate coordinates of pixels within circle.
skimage.draw.circle_perimeter Generate circle perimeter coordinates.
skimage.draw.ellipse Generate coordinates of pixels within ellipse.
skimage.draw.ellipse_perimeter Generate ellipse perimeter coordinates.
skimage.draw.line Generate line pixel coordinates.
skimage.draw.polygon Generate coordinates of pixels within polygon.
skimage.draw.set_color Set pixel color in the image at the given coordinates.

bresenham

skimage.draw.bresenham()

Generate line pixel coordinates.

Parameters :

y, x : int

Starting position (row, column).

y2, x2 : 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.

circle

skimage.draw.circle()

Generate coordinates of pixels within circle.

Parameters :

cy, cx : double

Centre coordinate of circle.

radius: double :

Radius of circle.

shape : tuple, optional

image shape which is used to determine maximum extents of output pixel coordinates. This is useful for circles which exceed the image size. By default the full extents of the circle are used.

Returns :

rr, cc : ndarray of int

Pixel coordinates of circle. May be used to directly index into an array, e.g. img[rr, cc] = 1.

Notes :

—– :

This function is a wrapper for skimage.draw.ellipse()

circle_perimeter

skimage.draw.circle_perimeter()

Generate circle perimeter coordinates.

Parameters :

cy, cx : int

Centre coordinate of circle.

radius: int :

Radius of circle.

method : {‘bresenham’, ‘andres’}, optional

bresenham : Bresenham method andres : Andres method

Returns :

rr, cc : (N,) ndarray of int

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

Notes

Andres method presents the advantage that concentric circles create a disc whereas Bresenham can make holes. There is also less distortions when Andres circles are rotated. Bresenham method is also known as midpoint circle algorithm.

References

[R30]J.E. Bresenham, “Algorithm for computer control of a digital plotter”, 4 (1965) 25-30.
[R31]
  1. Andres, “Discrete circles, rings and spheres”, 18 (1994) 695-706.

ellipse

skimage.draw.ellipse()

Generate coordinates of pixels within ellipse.

Parameters :

cy, cx : double

Centre coordinate of ellipse.

yradius, xradius : double

Minor and major semi-axes. (x/xradius)**2 + (y/yradius)**2 = 1.

shape : tuple, optional

image shape which is used to determine maximum extents of output pixel coordinates. This is useful for ellipses which exceed the image size. By default the full extents of the ellipse are used.

Returns :

rr, cc : ndarray of int

Pixel coordinates of ellipse. May be used to directly index into an array, e.g. img[rr, cc] = 1.

ellipse_perimeter

skimage.draw.ellipse_perimeter()

Generate ellipse perimeter coordinates.

Parameters :

cy, cx : int

Centre coordinate of ellipse.

yradius, xradius: int :

Main radial values.

Returns :

rr, cc : (N,) ndarray of int

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

References

[R32]J. Kennedy “A fast Bresenham type algorithm for drawing ellipses”.

line

skimage.draw.line()

Generate line pixel coordinates.

Parameters :

y, x : int

Starting position (row, column).

y2, x2 : 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.

polygon

skimage.draw.polygon()

Generate coordinates of pixels within polygon.

Parameters :

y : (N,) ndarray

Y-coordinates of vertices of polygon.

x : (N,) ndarray

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.

Returns :

rr, cc : ndarray of int

Pixel coordinates of polygon. May be used to directly index into an array, e.g. img[rr, cc] = 1.

set_color

skimage.draw.set_color()

Set pixel color in the image at the given coordinates.

Coordinates that exceed the shape of the image will be ignored.

Parameters :

img : (M, N, D) ndarray

Image

coords : ((P,) ndarray, (P,) ndarray)

Coordinates of pixels to be colored.

color : (D,) ndarray

Color to be assigned to coordinates in the image.

Returns :

img : (M, N, D) ndarray

The updated image.