machinevisiontoolbox.Image.decimate

Image.decimate(m=2, sigma=None)

Decimate an image

Parameters:
  • m (int) – decimation factor

  • sigma (float, optional) – standard deviation for Gaussian kernel smoothing, defaults to None

Raises:

ValueError – decimation factor m must be an integer

Returns:

decimated image

Return type:

Image

Return a decimated version of the image whose size is reduced by subsampling every m (an integer) pixels in both dimensions.

The image is smoothed with a Gaussian kernel with standard deviation sigma. If

  • sigma is None then a value of m/2 is used,

  • sigma is zero then no smoothing is performed.

Note:
  • If the image has multiple planes, each plane is decimated.

  • Smoothing is applied to the image _before_ decimation to reduce high-spatial-frequency components and reduce eliminate aliasing artifacts. The standard deviation should be chosen as a function of the maximum spatial-frequency in the image.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Random(6)
>>> img.print()
 153 225 207 228  23 155
 210 190 210 133 249  40
 235 238 176  78 156 227
  21 163 253 160 216 252
 172   7 209 172  86 203
 209  43 189  88 220 250
>>> img.decimate(2, sigma=0).print()
 153 207  23
 235 176 156
 172 209  86
References:
  • Robotics, Vision & Control for Python, Section 11.7.2, P. Corke, Springer 2023.

Seealso:

replicate scale