skimage2.transform.downscale_local_mean#
- skimage2.transform.downscale_local_mean(image, factors, cval=0, clip=True)[source]#
Down-sample N-dimensional image by local averaging.
The image is padded with
cvalif it is not perfectly divisible by the integer factors.In contrast to interpolation in
skimage.transform.resizeandskimage.transform.rescalethis function calculates the local mean of elements in each block of sizefactorsin the input image.- Parameters:
- image(M[, …]) ndarray
Input image.
- factorsarray_like
Array containing down-sampling integer factor along each axis.
- cvalfloat, optional
Constant padding value if image is not perfectly divisible by the integer factors.
- clipbool, optional
Unused, but kept here for API consistency with the other transforms in this module. (The local mean will never fall outside the range of values in the input image, assuming the provided
cvalalso falls within that range.)
- Returns:
- imagendarray
Down-sampled image with same number of dimensions as input image. For integer inputs, the output dtype will be
float64. Seenumpy.mean()for details.
Examples
>>> a = np.arange(15).reshape(3, 5) >>> a array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) >>> downscale_local_mean(a, (2, 3)) array([[3.5, 4. ], [5.5, 4.5]])