當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python skimage.draw.set_color用法及代碼示例

用法:

skimage.draw.set_color(image, coords, color, alpha=1)

在給定坐標處設置圖像中的像素顏色。

請注意,此函數會就地修改圖像的顏色。超出圖像形狀的坐標將被忽略。

參數

image(M, N, D) ndarray

圖片

coords((P,) ndarray, (P,) ndarray) 的元組

要著色的像素的行和列坐標。

color(D,) ndarray

分配給圖像中坐標的顏色。

alpha標量或 (N,) ndarray

用於將顏色與圖像混合的 Alpha 值。 0 是透明的,1 是不透明的。

例子

>>> 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)

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.draw.set_color。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。