用法:
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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。