
    9i                     >    S SK rSSKJr  S\R                  S S4S jrg)    N   )view_as_blocksc           
         [         R                  " U5      (       a  U4U R                  -  nO$[        U5      U R                  :w  a  [	        S5      eUc  0 n/ n[        [        U5      5       H]  nX   S:  a  [	        S5      eU R                  U   X   -  S:w  a  X   U R                  U   X   -  -
  nOSnUR                  SU45        M_     [         R                  " [         R                  " U5      5      (       a  [         R                  " XSUS9n [        X5      nU" U4S[        [        U R                  UR                  5      5      0UD6$ )a3  Downsample image by applying function `func` to local blocks.

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

Parameters
----------
image : (M[, ...]) ndarray
    N-dimensional input image.
block_size : array_like or int
    Array containing down-sampling integer factor along each axis.
    Default block_size is 2.
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 `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.

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]]])
zF`block_size` must be a scalar or have the same length as `image.shape`   zYDown-sampling factors must be >= 1. Use `skimage.transform.resize` to up-sample an image.r   constant)	pad_widthmodeconstant_valuesaxis)npisscalarndimlen
ValueErrorrangeshapeappendanyasarraypadr   tuple)	image
block_sizefunccvalfunc_kwargsr   iafter_widthblockeds	            U/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/measure/block.pyblock_reducer!      s5   t 
{{: ]UZZ/
	ZEJJ	&W
 	
 I3z?#=1 
 ;;q>JM)Q.$-5;;q>JM+IJKK![)* $ 
vvbjj#$$Z
 U/GTeE%**gll$CDTTT    )numpyr   utilr   sumr!    r"   r    <module>r'      s!     ! $%266t YUr"   