skimage 0.17.2

ParametersReturnsBackRef
view_as_blocks(arr_in, block_shape)

Blocks are non-overlapping views of the input array.

Parameters

arr_in : ndarray

N-d input array.

block_shape : tuple

The shape of the block. Each dimension must divide evenly into the corresponding dimensions of :None:None:`arr_in`.

Returns

arr_out : ndarray

Block view of the input array.

Block view of the input n-dimensional array (using re-striding).

Examples

This example is valid syntax, but we were not able to check execution
>>> import numpy as np
... from skimage.util.shape import view_as_blocks
... A = np.arange(4*4).reshape(4,4)
... A array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]])
This example is valid syntax, but we were not able to check execution
>>> B = view_as_blocks(A, block_shape=(2, 2))
... B[0, 0] array([[0, 1], [4, 5]])
This example is valid syntax, but we were not able to check execution
>>> B[0, 1]
array([[2, 3],
       [6, 7]])
This example is valid syntax, but we were not able to check execution
>>> B[1, 0, 1, 1]
13
This example is valid syntax, but we were not able to check execution
>>> A = np.arange(4*4*6).reshape(4,4,6)
... A # doctest: +NORMALIZE_WHITESPACE 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]]])
This example is valid syntax, but we were not able to check execution
>>> B = view_as_blocks(A, block_shape=(1, 2, 2))
... B.shape (4, 2, 3, 1, 2, 2)
This example is valid syntax, but we were not able to check execution
>>> B[2:, 0, 2]  # doctest: +NORMALIZE_WHITESPACE
array([[[[52, 53],
         [58, 59]]],
       [[[76, 77],
         [82, 83]]]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

skimage.util.shape.view_as_blocks

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /skimage/util/shape.py#9
type: <class 'function'>
Commit: