bundles / skimage 0.26.1rc0.dev0 / skimage / util / shape / view_as_blocks
function
skimage.util.shape:view_as_blocks
source: /_skimage2/util/shape.py:8
Signature
def view_as_blocks(arr_in, block_shape)Summary
Block view of the input n-dimensional array (using re-striding).
Extended Summary
Blocks are non-overlapping views of the input array.
Parameters
arr_in: ndarray, shape (M[, ...])Input array.
block_shape: tupleThe shape of the block. Each dimension must divide evenly into the corresponding dimensions of
arr_in.
Returns
arr_out: ndarrayBlock view of the input array.
Examples
import numpy as np from skimage.util.shape import view_as_blocks A = np.arange(4*4).reshape(4,4) A B = view_as_blocks(A, block_shape=(2, 2)) B[0, 0] B[0, 1]✓
array([[2, 3],
[6, 7]])
B[1, 0, 1, 1]
✗np.int64(13)
A = np.arange(4*4*6).reshape(4,4,6) A # doctest: +NORMALIZE_WHITESPACE B = view_as_blocks(A, block_shape=(1, 2, 2)) B.shape B[2:, 0, 2] # doctest: +NORMALIZE_WHITESPACE✓
array([[[[52, 53],
[58, 59]]],
[[[76, 77],
[82, 83]]]])
Aliases
skimage.util.view_as_blocks