用法:
skimage.measure.block_reduce(image, block_size=2, func=<function sum>, cval=0, func_kwargs=None)
通过将函数 func 应用于本地块来对图像进行下采样。
例如,此函数对于最大和均值池很有用。
- image:ndarray
N维输入图像。
- block_size:数组 或 int
包含沿每个轴的下采样整数因子的数组。默认 block_size 为 2。
- func:可调用的
用于计算每个本地块的返回值的函数对象。这个函数必须实现一个
axis
范围。主要函数是numpy.sum
,numpy.min
,numpy.max
,numpy.mean
和numpy.median
.也可以看看func_kwargs.- cval:浮点数
如果图像不能完全被块大小整除,则为常量填充值。
- func_kwargs:dict
传递给的关键字参数函数.对于将 dtype 参数传递给
np.mean
.接受输入字典,例如:func_kwargs={'dtype': np.float16})
.
- image:ndarray
与输入图像具有相同维度的下采样图像。
参数:
返回:
例子:
>>> from skimage.measure import block_reduce >>> image = np.arange(3*3*4).reshape(3, 3, 4) >>> image array([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]], [[12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23]], [[24, 25, 26, 27], [28, 29, 30, 31], [32, 33, 34, 35]]]) >>> block_reduce(image, block_size=(3, 3, 1), func=np.mean) array([[[16., 17., 18., 19.]]]) >>> image_max1 = block_reduce(image, block_size=(1, 3, 4), func=np.max) >>> image_max1 array([[[11]], [[23]], [[35]]]) >>> image_max2 = block_reduce(image, block_size=(3, 1, 4), func=np.max) >>> image_max2 array([[[27], [31], [35]]])
相关用法
- Python skimage.measure.ransac用法及代码示例
- Python skimage.measure.profile_line用法及代码示例
- Python skimage.measure.perimeter_crofton用法及代码示例
- Python skimage.measure.moments_hu用法及代码示例
- Python skimage.measure.moments_coords_central用法及代码示例
- Python skimage.measure.LineModelND用法及代码示例
- Python skimage.measure.moments用法及代码示例
- Python skimage.measure.shannon_entropy用法及代码示例
- Python skimage.measure.moments_normalized用法及代码示例
- Python skimage.measure.euler_number用法及代码示例
- Python skimage.measure.perimeter用法及代码示例
- 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.block_reduce。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。