Image.Hstack#

classmethod Image.Hstack(images: list[Any] | tuple[Any, ...], sep: int = 1, bgcolor: Any = None, return_offsets: bool = False) Any[source]#

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(size=(1280, 851), dtype=uint8, name='.../images/street.png')
>>> Image.Hstack((img, img, img))
Image(size=(3842, 851), dtype=uint8)
>>> Image.Hstack((img, img, img), return_offsets=True)
(Image(size=(3842, 851), dtype=uint8), [0, 1281, 2562])

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

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

Vstack Pstack Tile