skimage 0.17.2

ParametersReturnsBackRef
block_reduce(image, block_size, func=<function sum at 0x0000000>, cval=0, func_kwargs=None)

This function is useful for max and mean pooling, for example.

Parameters

image : ndarray

N-dimensional input image.

block_size : array_like

Array containing down-sampling integer factor along each axis.

func : callable

Function object which is used to calculate the return value for each local block. This function must implement an axis parameter. Primary functions are numpy.sum , numpy.min , numpy.max , numpy.mean and numpy.median . See also :None:None:`func_kwargs`.

cval : float

Constant padding value if image is not perfectly divisible by the block size.

func_kwargs : dict

Keyword arguments passed to func . Notably useful for passing dtype argument to np.mean . Takes dictionary of inputs, e.g.: func_kwargs={'dtype': np.float16}) .

Returns

image : ndarray

Down-sampled image with same number of dimensions as input image.

Downsample image by applying function func to local blocks.

Examples

This example is valid syntax, but we were not able to check execution
>>> from skimage.measure import block_reduce
... image = np.arange(3*3*4).reshape(3, 3, 4)
... image # 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]]])
This example is valid syntax, but we were not able to check execution
>>> block_reduce(image, block_size=(3, 3, 1), func=np.mean)
array([[[16., 17., 18., 19.]]])
This example is valid syntax, but we were not able to check execution
>>> image_max1 = block_reduce(image, block_size=(1, 3, 4), func=np.max)
... image_max1 # doctest: +NORMALIZE_WHITESPACE array([[[11]], [[23]], [[35]]])
This example is valid syntax, but we were not able to check execution
>>> image_max2 = block_reduce(image, block_size=(3, 1, 4), func=np.max)
... image_max2 # doctest: +NORMALIZE_WHITESPACE array([[[27], [31], [35]]])
See :

Back References

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

skimage.measure.block.block_reduce

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/measure/block.py#5
type: <class 'function'>
Commit: