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:
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. Ifsigmais None then a value ofm/2is used,sigmais 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() 111 161 152 148 53 42 35 12 47 36 107 200 64 0 35 150 234 40 164 197 233 80 96 117 36 73 116 212 61 179 100 154 32 137 41 13 >>> img.decimate(2, sigma=0).print() 111 152 53 64 35 234 36 116 61
- References:
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 11.7.2.
- Seealso: