This is a development version (0.26.1rc0.dev0) and may be unstable.Go to latest (0.26.1rc0.dev0+git20260530.b607368ff)
{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0 / skimage / draw / draw / set_color

function

skimage.draw.draw:set_color

source: /_skimage2/draw/draw.py:295

Signature

def set_color(image, coords, color, alpha = 1)

Summary

Set pixel color in the image at the given coordinates.

Extended Summary

Note that this function modifies the color of the image in-place. Coordinates that exceed the shape of the image will be ignored.

Parameters

image : ndarray of shape (M, N, C)

Image

coords : tuple of (ndarray of shape (K,), ...)

Row and column coordinates of pixels to be colored.

color : ndarray of shape (C,)

Color to be assigned to coordinates in the image.

alpha : np.number or ndarray of dtype np.number and shape (K,)

Alpha values used to blend color with image. 0 is transparent, 1 is opaque.

Examples

from skimage.draw import line, set_color
img = np.zeros((10, 10), dtype=np.uint8)
rr, cc = line(1, 1, 20, 20)
set_color(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, 1]], dtype=uint8)

Aliases

  • skimage.draw.set_color