rescale

rescale

skimage.transform.rescale(image, scale, order=1, mode='constant', cval=0, clip=True, preserve_range=False) [source]

Scale image by a certain factor.

Performs interpolation to upscale or down-scale images. For down-sampling N-dimensional images with integer factors by applying the arithmetic sum or mean, see skimage.measure.local_sum and skimage.transform.downscale_local_mean, respectively.

Parameters:

image : ndarray

Input image.

scale : {float, tuple of floats}

Scale factors. Separate scale factors can be defined as (row_scale, col_scale).

Returns:

scaled : ndarray

Scaled version of the input.

Other Parameters:

order : int, optional

The order of the spline interpolation, default is 1. The order has to be in the range 0-5. See skimage.transform.warp for 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.

cval : float, optional

Used in conjunction with mode ‘constant’, the value outside the image boundaries.

clip : bool, 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_range : bool, optional

Whether to keep the original range of values. Otherwise, the input image is converted according to the conventions of img_as_float.

Examples

>>> from skimage import data
>>> from skimage.transform import rescale
>>> image = data.camera()
>>> rescale(image, 0.1).shape
(51, 51)
>>> rescale(image, 0.5).shape
(256, 256)
doc_scikit_image
2017-01-12 17:23:10
Comments
Leave a Comment

Please login to continue.