skimage2.transform.resize_local_mean#

skimage2.transform.resize_local_mean(image, output_shape, grid_mode=True, preserve_range=False, *, channel_axis=None)[source]#

Resize an array with the local mean / bilinear scaling.

Parameters:
imagendarray

Input image. If this is a multichannel image, the axis corresponding to channels should be specified using channel_axis.

output_shapeiterable

Size of the generated output image. When channel_axis is not None, the channel_axis should either be omitted from output_shape or the output_shape[channel_axis] must match image.shape[channel_axis]. If the length of output_shape exceeds image.ndim, additional singleton dimensions will be appended to the input image as needed.

grid_modebool, optional

Defines image pixels position: if True, pixels are assumed to be at grid intersections, otherwise at cell centers. As a consequence, for example, a 1d signal of length 5 is considered to have length 4 when grid_mode is False, but length 5 when grid_mode is True. See the following visual illustration:

| pixel 1 | pixel 2 | pixel 3 | pixel 4 | pixel 5 |
     |<-------------------------------------->|
                        vs.
|<----------------------------------------------->|

The starting point of the arrow in the diagram above corresponds to coordinate location 0 in each mode.

preserve_rangebool, optional

Whether to keep the original range of values. Otherwise, the input image is converted according to the conventions of img_as_float. Also see https://scikit-image.org/docs/dev/user_guide/data_types.html

channel_axisint or None, optional

If None, the image is assumed to be a grayscale (single channel) image. Otherwise, this parameter indicates which axis of the array corresponds to channels.

Returns:
resizedndarray

Resized version of the input.

Notes

This method is sometimes referred to as “area-based” interpolation or “pixel mixing” interpolation [1]. When grid_mode is True, it is equivalent to using OpenCV’s resize with INTER_AREA interpolation mode. It is commonly used for image downsizing. If the downsizing factors are integers, then downscale_local_mean should be preferred instead.

References

Examples

>>> from _skimage2 import data
>>> from _skimage2.transform import resize_local_mean
>>> image = data.camera()
>>> resize_local_mean(image, (100, 100)).shape
(100, 100)