machinevisiontoolbox.Image.Hstack

classmethod Image.Hstack(images, sep=1, bgcolor=None, return_offsets=False)

Horizontal concatenation of images

Parameters:
  • images (iterable of Image) – images to concatenate horizontally

  • sep (int, optional) – separation between images, defaults to 1

  • bgcolor (scalar, string, array_like, optional) – color of background, seen in the separation between images, defaults to black

  • return_offsets (bool, optional) – additionally return the horizontal coordinates of each input image within the output image, defaults to False

Raises:
  • ValueError – all images must have the same dtype

  • ValueError – all images must have the same color order

Returns:

horizontally stacked images

Return type:

Image

Create a new image by stacking the input images horizontally, with a vertical separator line of width sep and color bgcolor.

The horizontal coordinate of the first column of each image, in the composite output image, can be optionally returned if return_offsets is True.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('street.png')
>>> img
Image: 1280 x 851 (uint8) [.../images/street.png]
>>> Image.Hstack((img, img, img))
Image: 3842 x 851 (uint8)
>>> Image.Hstack((img, img, img), return_offsets=True)
(Image: 3842 x 851 (uint8), [0, 1281, 2562])

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

../_images/machinevisiontoolbox-Image-Hstack-1.png
Seealso:

Vstack Tile