Image.pad#

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

Pad the edges of the image

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

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

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

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

  • value (scalar, str, array_like) – value of pixels to pad with

Returns:

padded image

Return type:

Image

Pad the edges of the image with pixels equal to value.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('flowers1.png', dtype='float')
>>> img
Image(size=(640, 426), dtype=float32, nplanes=3, colororder=R:G:B, name='.../images/flowers1.png')
>>> img.pad(left=10, bottom=10, top=10, right=10, value='r')
Image(size=(660, 446), dtype=float32, nplanes=3, colororder=R:G:B)

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

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