用法:
cucim.skimage.util.view_as_blocks(arr_in, block_shape)
输入 n 维数组的块视图(使用重新跨步)。
块是输入数组的非重叠视图。
- arr_in:ndarray
N-d 输入数组。
- block_shape:元组
块的形状。每个维度必须平均划分为
arr_in
的相应维度。
- arr_out:ndarray
输入数组的块视图。如果
arr_in
不连续,则制作一个副本。
参数:
返回:
例子:
>>> import cupy as cp >>> from cucim.skimage.util.shape import view_as_blocks >>> A = cp.arange(4*4).reshape(4,4) >>> A array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> B = view_as_blocks(A, block_shape=(2, 2)) >>> B[0, 0] array([[0, 1], [4, 5]]) >>> B[0, 1] array([[2, 3], [6, 7]]) >>> B[1, 0, 1, 1] 13
>>> A = cp.arange(4*4*6).reshape(4,4,6) >>> A 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], [36, 37, 38, 39, 40, 41], [42, 43, 44, 45, 46, 47]], [[48, 49, 50, 51, 52, 53], [54, 55, 56, 57, 58, 59], [60, 61, 62, 63, 64, 65], [66, 67, 68, 69, 70, 71]], [[72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83], [84, 85, 86, 87, 88, 89], [90, 91, 92, 93, 94, 95]]]) >>> B = view_as_blocks(A, block_shape=(1, 2, 2)) >>> B.shape (4, 2, 3, 1, 2, 2) >>> B[2:, 0, 2] array([[[[52, 53], [58, 59]]], [[[76, 77], [82, 83]]]])
相关用法
- Python cucim.skimage.util.view_as_windows用法及代码示例
- Python cucim.skimage.util.invert用法及代码示例
- Python cucim.skimage.feature.shape_index用法及代码示例
- Python cucim.skimage.restoration.richardson_lucy用法及代码示例
- Python cucim.skimage.data.binary_blobs用法及代码示例
- Python cucim.skimage.filters.roberts_neg_diag用法及代码示例
- Python cucim.skimage.color.lch2lab用法及代码示例
- Python cucim.skimage.measure.label用法及代码示例
- Python cucim.skimage.color.rgb2gray用法及代码示例
- Python cucim.skimage.filters.gabor用法及代码示例
- Python cucim.skimage.transform.rescale用法及代码示例
- Python cucim.skimage.filters.roberts_pos_diag用法及代码示例
- Python cucim.skimage.segmentation.random_walker用法及代码示例
- Python cucim.skimage.filters.roberts用法及代码示例
- Python cucim.skimage.morphology.dilation用法及代码示例
- Python cucim.skimage.feature.corner_foerstner用法及代码示例
- Python cucim.skimage.measure.moments_coords用法及代码示例
- Python cucim.skimage.filters.gabor_kernel用法及代码示例
- Python cucim.skimage.color.hsv2rgb用法及代码示例
- Python cucim.skimage.morphology.closing用法及代码示例
注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cucim.skimage.util.view_as_blocks。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。