用法:
skimage.draw.circle_perimeter(r, c, radius, method='bresenham', shape=None)
生成圓周長坐標。
- r, c:int
圓的中心坐標。
- radius:int
圓的半徑。
- method:{‘bresenham’, ‘andres’},可選
bresenham:Bresenham 方法(默認) andres:Andres 方法
- shape:元組,可選
用於確定輸出像素坐標的最大範圍的圖像形狀。這對於超過圖像大小的圓圈很有用。如果沒有,則使用圓的完整範圍。長度必須至少為 2。隻有前兩個值用於確定輸入圖像的範圍。
- rr, cc:(N,)int的ndarray
Bresenham 和 Andres 的方法:屬於圓周長的像素的索引。可用於直接索引到數組中,例如
img[rr, cc] = 1
。
參數:
返回:
注意:
安德烈斯方法具有同心圓形成圓盤的優點,而布雷森漢姆可以製造孔。旋轉安德烈斯圓時失真也較小。 Bresenham 方法也稱為中點圓算法。
circle_perimeter_aa
參考:
- 1
J.E. Bresenham, “Algorithm for computer control of a digital plotter”, IBM Systems journal, 4 (1965) 25-30.
- 2
E. Andres, “Discrete circles, rings and spheres”, Computers & Graphics, 18 (1994) 695-706.
例子:
>>> from skimage.draw import circle_perimeter >>> img = np.zeros((10, 10), dtype=np.uint8) >>> rr, cc = circle_perimeter(4, 4, 3) >>> img[rr, cc] = 1 >>> img array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 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)
相關用法
- Python skimage.draw.circle_perimeter_aa用法及代碼示例
- Python skimage.draw.random_shapes用法及代碼示例
- Python skimage.draw.polygon2mask用法及代碼示例
- Python skimage.draw.ellipse_perimeter用法及代碼示例
- Python skimage.draw.bezier_curve用法及代碼示例
- Python skimage.draw.line用法及代碼示例
- Python skimage.draw.set_color用法及代碼示例
- Python skimage.draw.polygon用法及代碼示例
- Python skimage.draw.rectangle_perimeter用法及代碼示例
- Python skimage.draw.ellipse用法及代碼示例
- Python skimage.draw.polygon_perimeter用法及代碼示例
- Python skimage.draw.line_nd用法及代碼示例
- Python skimage.draw.disk用法及代碼示例
- Python skimage.draw.rectangle用法及代碼示例
- Python skimage.draw.line_aa用法及代碼示例
- Python skimage.data.binary_blobs用法及代碼示例
- Python skimage.data.file_hash用法及代碼示例
- Python skimage.feature.graycomatrix用法及代碼示例
- Python skimage.color.lab2lch用法及代碼示例
- Python skimage.feature.blob_doh用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.draw.circle_perimeter。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。