Image.pyramid#
- Image.pyramid(sigma: int | float = 1, N: int | None = None, border: str = 'replicate', bordervalue: int | float = 0) list[Any][source]#
Pyramidal image decomposition
- Parameters:
sigma (float) – standard deviation of Gaussian kernel
N (int, optional) – number of pyramid levels to be computed, defaults to all
border (str, optional) – option for boundary handling, see
convolve, defaults to ‘replicate’bordervalue (scalar, optional) – padding value, defaults to 0
- Returns:
list of images at each pyramid level
- Return type:
list of
Image
Returns a pyramid decomposition of the input image using Gaussian smoothing with standard deviation of
sigma. The return is a list array of images each one having dimensions half that of the previous image. The pyramid is computed down to a non-halvable image size.Example:
>>> from machinevisiontoolbox import Image >>> img = Image.Read('monalisa.png') >>> pyramid = img.pyramid(4) >>> len(pyramid) 11 >>> pyramid [Image(size=(677, 700), dtype=uint8), Image(size=(339, 350), dtype=uint8), Image(size=(170, 175), dtype=uint8), Image(size=(85, 88), dtype=uint8), Image(size=(43, 44), dtype=uint8), Image(size=(22, 22), dtype=uint8), Image(size=(11, 11), dtype=uint8), Image(size=(6, 6), dtype=uint8), Image(size=(3, 3), dtype=uint8), Image(size=(2, 2), dtype=uint8), Image(size=(1, 1), dtype=uint8)]
Note
Works for greyscale images only.
Converts a color image to greyscale.
- References:
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 12.3.2.
Important
Uses OpenCV function
cv2.pyrDownwhich accepts single-channel, CV_8U, CV_16U, CV_16S, CV_32F or CV_64F images (color images are automatically converted to greyscale).- Seealso: