skimage2.transform.rescale#
- skimage2.transform.rescale(image, scale, order=None, mode='reflect', cval=0, clip=True, preserve_range=False, anti_aliasing=None, anti_aliasing_sigma=None, *, channel_axis=None)[source]#
Scale image by a certain factor.
Performs interpolation to up-scale or down-scale N-dimensional images. Note that anti-aliasing should be enabled when down-sizing images to avoid aliasing artifacts. For down-sampling with an integer factor also see
skimage.transform.downscale_local_mean.- Parameters:
- image(M, N[, âĶ][, C]) ndarray
Input image.
- scale{float, tuple of floats}
Scale factors for spatial dimensions. Separate scale factors can be defined as (m, n[, âĶ]).
- Returns:
- scaledndarray
Scaled version of the input.
- Other Parameters:
- orderint, optional
The order of the spline interpolation, default is 0 if image.dtype is bool and 1 otherwise. The order has to be in the range 0-5. See
skimage.transform.warpfor detail.- mode{âconstantâ, âedgeâ, âsymmetricâ, âreflectâ, âwrapâ}, optional
Points outside the boundaries of the input are filled according to the given mode. Modes match the behaviour of
numpy.pad.- cvalfloat, optional
Used in conjunction with mode âconstantâ, the value outside the image boundaries.
- clipbool, optional
Whether to clip the output to the range of values of the input image. This is enabled by default, since higher order interpolation may produce values outside the given input range.
- 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- anti_aliasingbool, optional
Whether to apply a Gaussian filter to smooth the image prior to down-scaling. It is crucial to filter when down-sampling the image to avoid aliasing artifacts. If input image data type is bool, no anti-aliasing is applied.
- anti_aliasing_sigma{float, tuple of floats}, optional
Standard deviation for Gaussian filtering to avoid aliasing artifacts. By default, this value is chosen as (s - 1) / 2 where s is the down-scaling factor.
- 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.
Added in version 0.19:
channel_axiswas added in 0.19.
Notes
Modes âreflectâ and âsymmetricâ are similar, but differ in whether the edge pixels are duplicated during the reflection. As an example, if an array has values [0, 1, 2] and was padded to the right by four values using symmetric, the result would be [0, 1, 2, 2, 1, 0, 0], while for reflect it would be [0, 1, 2, 1, 0, 1, 2].
Examples
>>> from _skimage2 import data >>> from _skimage2.transform import rescale >>> image = data.camera() >>> rescale(image, 0.1).shape (51, 51) >>> rescale(image, 0.5).shape (256, 256)