bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / transform / _warps / rescale
function
skimage.transform._warps:rescale
source: /dev/scikit-image/src/skimage/transform/_warps.py :228
Signature
def rescale ( image , scale , order = None , mode = reflect , cval = 0 , clip = True , preserve_range = False , anti_aliasing = None , anti_aliasing_sigma = None , * , channel_axis = None ) Summary
Scale image by a certain factor.
Extended Summary
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]) ndarrayInput image.
scale: {float, tuple of floats}Scale factors for spatial dimensions. Separate scale factors can be defined as (m, n[, ...]).
Returns
scaled: ndarrayScaled version of the input.
Other Parameters
order: int, optionalThe 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.warp for detail.
mode: {'constant', 'edge', 'symmetric', 'reflect', 'wrap'}, optionalPoints outside the boundaries of the input are filled according to the given mode. Modes match the behaviour of numpy.pad.
cval: float, optionalUsed in conjunction with mode 'constant', the value outside the image boundaries.
clip: bool, optionalWhether 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_range: bool, optionalWhether 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_aliasing: bool, optionalWhether 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}, optionalStandard 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_axis: int or None, optionalIf None, the image is assumed to be a grayscale (single channel) image. Otherwise, this parameter indicates which axis of the array corresponds to channels.
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 skimage import data from skimage.transform import rescale image = data.camera() rescale(image, 0.1).shape rescale(image, 0.5).shape✓
Aliases
-
skimage.transform.rescale