Module Import alias identifier ImportFrom alias alias FunctionDef arguments args NameParam NameParam NameParam NameParam defaults AttributeLoad NameLoad attr Num body Expr Str If CompareNotEq Call NameLoad NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad Str Assign NameStore ListLoad For NameStore Call NameLoad Call NameLoad NameLoad body If CompareLt SubscriptLoad NameLoad Index NameLoad Num body Raise Call NameLoad Str If CompareNotEq BinOpMod SubscriptLoad AttributeLoad NameLoad attr Index NameLoad SubscriptLoad NameLoad Index NameLoad Num body Assign NameStore BinOpSub SubscriptLoad NameLoad Index NameLoad BinOpMod SubscriptLoad AttributeLoad NameLoad attr Index NameLoad SubscriptLoad NameLoad Index NameLoad orelse Assign NameStore Num Expr Call AttributeLoad NameLoad attr TupleLoad Num NameLoad Assign NameStore Call NameLoad NameLoad keyword NameLoad keyword Str keyword NameLoad Assign NameStore Call NameLoad NameLoad NameLoad For NameStore Call NameLoad BinOpFloorDiv Call NameLoad AttributeLoad NameLoad attr Num body Assign NameStore Call NameLoad NameLoad keyword Num Return NameLoad decorator_list
N/A N/A numpy np util view_as_blocks pad block_reduce N/A N/A image block_size func cval N/A N/A np sum 0 N/A N/A Down-sample image by applying function to local blocks.

    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 such
        as ``numpy.sum`` or ``numpy.min``.
    cval : float
        Constant padding value if image is not perfectly divisible by the
        block size.

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

    Examples
    --------
    >>> 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]]])
    >>> 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 # doctest: +NORMALIZE_WHITESPACE
    array([[[11]],
           [[23]],
           [[35]]])
    >>> image_max2 = block_reduce(image, block_size=(3, 1, 4), func=np.max)
    >>> image_max2 # doctest: +NORMALIZE_WHITESPACE
    array([[[27],
            [31],
            [35]]])
     N/A N/A N/A len block_size N/A image ndim N/A N/A N/A ValueError `block_size` must have the same length as `image.shape`. N/A pad_width N/A N/A i N/A range N/A len block_size N/A N/A N/A N/A block_size N/A i 1 N/A N/A N/A ValueError Down-sampling factors must be >= 1. Use `skimage.transform.resize` to up-sample an image. N/A N/A N/A N/A N/A image shape N/A i N/A block_size N/A i 0 N/A N/A after_width N/A N/A block_size N/A i N/A N/A N/A image shape N/A i N/A block_size N/A i N/A N/A after_width 0 N/A N/A N/A pad_width append N/A 0 after_width N/A image N/A pad image pad_width pad_width mode constant constant_values cval N/A out N/A view_as_blocks image block_size N/A i N/A range N/A N/A len N/A out shape 2 N/A N/A out N/A func out axis -1 N/A out N/A