Image.scale#

Image.scale(sfactor: float, sigma: float | None = None, interpolation: str | None = None) Self[source]#

Scale an image

Parameters:
  • sfactor (scalar) – scale factor

  • sigma (float) – standard deviation of kernel for image smoothing, in pixels

Raises:
  • ValueError – bad interpolation string

  • ValueError – bad interpolation value

Returns:

smoothed image

Return type:

Image instance

Rescale the image. If sfactor> 1 the image is enlarged.

If sfactor < 1 the image is made smaller and smoothing can be applied to reduce sampling artefacts. If sigma is None, use default for scale by sigma=1/sfactor/2. If sigma=0 perform no smoothing.

interpolation

description

'cubic'

bicubic interpolation

'linear'

bilinear interpolation

'area'

resampling using pixel area relation

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('monalisa.png')
>>> img.scale(2)
Image(size=(1354, 1400), dtype=uint8, nplanes=3, colororder=R:G:B)
>>> img.scale(0.5)
Image(size=(338, 350), dtype=uint8, nplanes=3, colororder=R:G:B)
References:
Seealso:

opencv.resize