用法:
skimage.measure.profile_line(image, src, dst, linewidth=1, order=None, mode='reflect', cval=0.0, *, reduce_func=<function mean>)
返回沿扫描线测量的图像的强度分布。
- image:ndarray,形状(M,N[,C])
图像,灰度(2D 阵列)或多通道(3D 阵列,其中最后一个轴包含通道信息)。
- src:数组, 形状 (2, )
扫描线起点的坐标。
- dst:数组, 形状 (2, )
扫描线终点的坐标。与标准 numpy 索引相比,目标点包含在配置文件中。
- linewidth:int 可选
扫描的宽度,垂直于线
- order:int in {0, 1, 2, 3, 4, 5},可选
样条插值的顺序,如果 image.dtype 为 bool 则默认为 0,否则为 1。顺序必须在 0-5 范围内。有关详细信息,请参阅
skimage.transform.warp
- mode:{‘constant’, ‘nearest’, ‘reflect’, ‘mirror’, ‘wrap’},可选
如何计算图像之外的任何值。
- cval:浮点数,可选
如果模式是‘constant’,在图像外使用什么常量值。
- reduce_func:可调用的,可选的
当 linewidth > 1 时,用于计算垂直于profile_line 方向的像素值聚合的函数。如果设置为 None,将返回未归约的数组。
- return_value:数组
沿扫描线的强度分布。轮廓的长度是计算出的扫描线长度的上限。
参数:
返回:
例子:
>>> x = np.array([[1, 1, 1, 2, 2, 2]]) >>> img = np.vstack([np.zeros_like(x), x, x, x, np.zeros_like(x)]) >>> img array([[0, 0, 0, 0, 0, 0], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [0, 0, 0, 0, 0, 0]]) >>> profile_line(img, (2, 1), (2, 4)) array([1., 1., 2., 2.]) >>> profile_line(img, (1, 0), (1, 6), cval=4) array([1., 1., 1., 2., 2., 2., 2.])
与标准 numpy 索引相比,目标点包含在配置文件中。例如:
>>> profile_line(img, (1, 0), (1, 6)) # The final point is out of bounds array([1., 1., 1., 2., 2., 2., 2.]) >>> profile_line(img, (1, 0), (1, 5)) # This accesses the full first row array([1., 1., 1., 2., 2., 2.])
对于不同的 reduce_func 输入:
>>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.mean) array([0.66666667, 0.66666667, 0.66666667, 1.33333333]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.max) array([1, 1, 1, 2]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sum) array([2, 2, 2, 4])
当reduce_func 为 None 或当reduce_func 单独作用于每个像素值时,将返回未归约的数组。
>>> profile_line(img, (1, 2), (4, 2), linewidth=3, order=0, ... reduce_func=None) array([[1, 1, 2], [1, 1, 2], [1, 1, 2], [0, 0, 0]]) >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sqrt) array([[1. , 1. , 0. ], [1. , 1. , 0. ], [1. , 1. , 0. ], [1.41421356, 1.41421356, 0. ]])
相关用法
- Python skimage.measure.perimeter_crofton用法及代码示例
- Python skimage.measure.perimeter用法及代码示例
- Python skimage.measure.ransac用法及代码示例
- Python skimage.measure.moments_hu用法及代码示例
- Python skimage.measure.moments_coords_central用法及代码示例
- Python skimage.measure.LineModelND用法及代码示例
- Python skimage.measure.block_reduce用法及代码示例
- Python skimage.measure.moments用法及代码示例
- Python skimage.measure.shannon_entropy用法及代码示例
- Python skimage.measure.moments_normalized用法及代码示例
- Python skimage.measure.euler_number用法及代码示例
- Python skimage.measure.moments_central用法及代码示例
- Python skimage.measure.EllipseModel用法及代码示例
- Python skimage.measure.regionprops用法及代码示例
- Python skimage.measure.find_contours用法及代码示例
- Python skimage.measure.CircleModel用法及代码示例
- Python skimage.measure.label用法及代码示例
- Python skimage.measure.regionprops_table用法及代码示例
- Python skimage.measure.moments_coords用法及代码示例
- Python skimage.metrics.hausdorff_distance用法及代码示例
注:本文由纯净天空筛选整理自scikit-image.org大神的英文原创作品 skimage.measure.profile_line。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。