machinevisiontoolbox.Image.trim

Image.trim(left=0, right=0, top=0, bottom=0)

Trim pixels from the edges of the image

Parameters:
  • left (int, optional) – number of pixels to trim from left side of image, defaults to 0

  • right (int, optional) – number of pixels to trim from right side of image, defaults to 0

  • top (int, optional) – number of pixels to trim from top side of image, defaults to 0

  • bottom (int, optional) – number of pixels to trim from bottom side of image, defaults to 0

Returns:

trimmed image

Return type:

Image

Trim pixels from the edges of the image.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('flowers1.png')
>>> img
Image: 640 x 426 (uint8), R:G:B [.../images/flowers1.png]
>>> img.trim(left=100, bottom=100)
Image: 540 x 326 (uint8), R:G:B

(Source code, png, hires.png, pdf)

../_images/machinevisiontoolbox-Image-trim-1.png