Image.trim#

Image.trim(left: int = 0, right: int = 0, top: int = 0, bottom: int = 0) Self[source]#

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(size=(640, 426), dtype=uint8, nplanes=3, colororder=R:G:B, name='.../images/flowers1.png')
>>> img.trim(left=100, bottom=100)
Image(size=(540, 326), dtype=uint8, nplanes=3, colororder=R:G:B)

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

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