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()
  10   9  35 214  97  94
  84 192 221  76  64  58
 114  20 141   7  42 179
 157  36 144  63  62  95
 181  63 232 191 138 125
 187  95 174 215 184 142
>>> img.decimate(2, sigma=0).print()
  10  35  97
 114 141  42
 181 232 138
References:
  • Robotics, Vision & Control for Python, Section 11.7.2, P. Corke, Springer 2023.

Seealso:

replicate scale