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


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

用法:

skimage.draw.circle_perimeter_aa(r, c, radius, shape=None)

生成抗鋸齒圓周長坐標。

參數

r, cint

圓的中心坐標。

radiusint

圓的半徑。

shape元組,可選

用於確定輸出像素坐標的最大範圍的圖像形狀。這對於超過圖像大小的圓圈很有用。如果沒有,則使用圓的完整範圍。長度必須至少為 2。隻有前兩個值用於確定輸入圖像的範圍。

返回

rr, cc, val(N,) ndarray (int, int 浮點數)

像素 index (rr,抄送) 和強度值 ()。img[rr, cc] = val.

注意

Wu 的方法是繪製抗鋸齒圓。此實現不使用查找表優化。

使用函數draw.set_colorcircle_perimeter_aa 結果應用於彩色圖像。

參考

1

X. Wu, “An efficient antialiasing technique”, In ACM SIGGRAPH Computer Graphics, 25 (1991) 143-152.

例子

>>> from skimage.draw import circle_perimeter_aa
>>> img = np.zeros((10, 10), dtype=np.uint8)
>>> rr, cc, val = circle_perimeter_aa(4, 4, 3)
>>> img[rr, cc] = val * 255
>>> img
array([[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,  60, 211, 255, 211,  60,   0,   0,   0],
       [  0,  60, 194,  43,   0,  43, 194,  60,   0,   0],
       [  0, 211,  43,   0,   0,   0,  43, 211,   0,   0],
       [  0, 255,   0,   0,   0,   0,   0, 255,   0,   0],
       [  0, 211,  43,   0,   0,   0,  43, 211,   0,   0],
       [  0,  60, 194,  43,   0,  43, 194,  60,   0,   0],
       [  0,   0,  60, 211, 255, 211,  60,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0],
       [  0,   0,   0,   0,   0,   0,   0,   0,   0,   0]], dtype=uint8)
>>> from skimage import data, draw
>>> image = data.chelsea()
>>> rr, cc, val = draw.circle_perimeter_aa(r=100, c=100, radius=75)
>>> draw.set_color(image, (rr, cc), [1, 0, 0], alpha=val)

相關用法


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