Image.decimate#

Image.decimate(m: int = 2, sigma: float | None = None) → Self[source]#

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 hence reduce 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(size=6)
>>> img.print()
    79 121  57 122   2 224
   106 145  44 189   8 105
    42 111 192  46  76  93
    36   2 175 180 102  45
   190  82  38 213  83  33
   246  27   0 142 237 195
>>> img.decimate(2, sigma=0).print()
    79  57   2
    42 192  76
   190  38  83
References:
Seealso:

replicate scale