lentil.rescale

lentil.rescale(img, scale, shape=None, mask=None, order=3, mode='nearest', unitary=True)[source]

Rescale an image by interpolation.

Parameters
  • img (array_like) – Image to rescale

  • scale (float) – Scaling factor. Scale factors less than 1 will shrink the image. Scale factors greater than 1 will grow the image.

  • shape (array_like or int, optional) – Output shape. If None (default), the output shape will be the input img shape multiplied by the scale factor.

  • mask (array_like, optional) – Binary mask applied after rescaling. If None (default), a mask is created from the nonzero portions of img. To skip masking operation, set mask = np.ones_like(img)

  • order (int, optional) – Order of spline interpolation used for rescaling operation. Default is 3. Order must be in the range 0-5.

  • mode ({'constant', 'nearest', 'reflect', 'wrap'}, optional) – Points outside the boundaries of the input are filled according to the given mode. Default is ‘constant’.

  • unitary (bool, optional) – Normalization flag. If True (default), a normalization is performed on the output such that the rescaling operation is unitary and image power (if complex) or intensity (if real) is conserved.

Returns

img – Rescaled image.

Return type

ndarray

Note

The post-rescale masking operation should have no real effect on the resulting image but is included to eliminate interpolation artifacts that sometimes appear in large clusters of zeros in rescaled images.

See also

rebin()