resize
-
skimage.transform.resize(image, output_shape, order=1, mode='constant', cval=0, clip=True, preserve_range=False)
[source] -
Resize image to match a certain size.
Performs interpolation to up-size or down-size images. For down-sampling N-dimensional images by applying the arithmetic sum or mean, see
skimage.measure.local_sum
andskimage.transform.downscale_local_mean
, respectively.Parameters: image : ndarray
Input image.
output_shape : tuple or ndarray
Size of the generated output image
(rows, cols[, dim])
. Ifdim
is not provided, the number of channels is preserved. In case the number of input channels does not equal the number of output channels a 3-dimensional interpolation is applied.Returns: resized : ndarray
Resized 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
.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 resize >>> image = data.camera() >>> resize(image, (100, 100)).shape (100, 100)
Please login to continue.