set-color

set_color

skimage.draw.set_color(img, coords, color, alpha=1) [source]

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 : tuple of ((P,) ndarray, (P,) ndarray)

Row and column coordinates of pixels to be colored.

color : (D,) ndarray

Color to be assigned to coordinates in the image.

alpha : scalar or (N,) ndarray

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

Returns:

img : (M, N, D) ndarray

The updated image.

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)
doc_scikit_image
2017-01-12 17:23:28
Comments
Leave a Comment

Please login to continue.