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_axisis not None, thechannel_axisshould either be omitted fromoutput_shapeor theoutput_shape[channel_axis]must matchimage.shape[channel_axis]. If the length ofoutput_shapeexceeds image.ndim, additional singleton dimensions will be appended to the inputimageas needed.- grid_modebool, optional
Defines
imagepixels 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 whengrid_modeis False, but length 5 whengrid_modeis 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.
See also
Notes
This method is sometimes referred to as âarea-basedâ interpolation or âpixel mixingâ interpolation [1]. When
grid_modeis True, it is equivalent to using OpenCVâs resize withINTER_AREAinterpolation mode. It is commonly used for image downsizing. If the downsizing factors are integers, thendownscale_local_meanshould 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)