用法:
skimage.draw.ellipse_perimeter(r, c, r_radius, c_radius, orientation=0, shape=None)
生成椭圆周长坐标。
- r, c:int
椭圆的中心坐标。
- r_radius, c_radius:int
次要和主要半轴。
(r/r_radius)**2 + (c/c_radius)**2 = 1
。- orientation:双,可选
顺时针方向的长轴方向,以弧度表示。
- shape:元组,可选
用于确定输出像素坐标的最大范围的图像形状。这对于超出图像大小的椭圆很有用。如果没有,则使用椭圆的全部范围。长度必须至少为 2。只有前两个值用于确定输入图像的范围。
- rr, cc:(N,)int的ndarray
属于椭圆周长的像素的索引。可用于直接索引到数组中,例如
img[rr, cc] = 1
。
参数:
返回:
参考:
- 1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf
例子:
>>> from skimage.draw import ellipse_perimeter >>> img = np.zeros((10, 10), dtype=np.uint8) >>> rr, cc = ellipse_perimeter(5, 5, 3, 4) >>> 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, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
注意的位置skimage.draw.ellipse未指定形状也可以有负值,因为这在飞机上是正确的。另一方面,之后将这些椭圆位置用于图像可能会导致出现在图像的另一侧,因为
image[-1, -1] = image[end-1, end-1]
>>> rr, cc = ellipse_perimeter(2, 3, 4, 5) >>> img = np.zeros((9, 12), dtype=np.uint8) >>> img[rr, cc] = 1 >>> img array([[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]], dtype=uint8)
相关用法
- Python skimage.draw.ellipse用法及代码示例
- 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_perimeter。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。