用法:
skimage.draw.ellipse(r, c, r_radius, c_radius, shape=None, rotation=0.0)
生成橢圓內的像素坐標。
- r, c:雙倍的
橢圓的中心坐標。
- r_radius, c_radius:雙倍的
次要和主要半軸。
(r/r_radius)**2 + (c/c_radius)**2 = 1
。- shape:元組,可選
用於確定輸出像素坐標的最大範圍的圖像形狀。這對於超出圖像大小的橢圓很有用。默認情況下,使用橢圓的完整範圍。長度必須至少為 2。隻有前兩個值用於確定範圍。
- rotation:浮點數,可選(默認為 0。)
在逆時針方向設置橢圓旋轉(-PI,PI)範圍內的橢圓旋轉(旋轉),因此PI /2度表示交換橢圓軸
- rr, cc:int的ndarray
橢圓的像素坐標。可用於直接索引到數組中,例如
img[rr, cc] = 1
。
參數:
返回:
注意:
橢圓方程:
((x * cos(alpha) + y * sin(alpha)) / x_radius) ** 2 + ((x * sin(alpha) - y * cos(alpha)) / y_radius) ** 2 = 1
注意的位置skimage.draw.ellipse未指定形狀也可以有負值,因為這在飛機上是正確的。另一方麵,之後將這些橢圓位置用於圖像可能會導致出現在圖像的另一側,因為
image[-1, -1] = image[end-1, end-1]
>>> rr, cc = ellipse(1, 2, 3, 6) >>> img = np.zeros((6, 12), dtype=np.uint8) >>> img[rr, cc] = 1 >>> img array([[1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1]], dtype=uint8)
例子:
>>> from skimage.draw import ellipse >>> img = np.zeros((10, 12), dtype=np.uint8) >>> rr, cc = ellipse(5, 6, 3, 5, rotation=np.deg2rad(30)) >>> img[rr, cc] = 1 >>> img array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
相關用法
- Python skimage.draw.ellipse_perimeter用法及代碼示例
- Python skimage.draw.random_shapes用法及代碼示例
- Python skimage.draw.polygon2mask用法及代碼示例
- Python skimage.draw.bezier_curve用法及代碼示例
- Python skimage.draw.line用法及代碼示例
- Python skimage.draw.set_color用法及代碼示例
- Python skimage.draw.circle_perimeter用法及代碼示例
- Python skimage.draw.polygon用法及代碼示例
- Python skimage.draw.rectangle_perimeter用法及代碼示例
- Python skimage.draw.polygon_perimeter用法及代碼示例
- Python skimage.draw.circle_perimeter_aa用法及代碼示例
- 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.ellipse。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。