machinevisiontoolbox.Image.Overlay

classmethod Image.Overlay(im1, im2, colors='rc')

Overlay two greyscale images in different colors

Parameters:
  • im1 (Image) – first image

  • im2 (Image) – second image

  • colors (2-element string/list/tuple, optional) – colors for each image, defaults to ‘rc’’

Raises:

ValueError – images must be greyscale

Returns:

overlaid images

Return type:

Image

Two greyscale images are overlaid in different colors. Useful for visualizing disparity or optical flow.

Example:

>>> from machinevisiontoolbox import Image
>>> img1 = Image.Read('eiffel-1.png', mono=True)
>>> img2 = Image.Read('eiffel-2.png', mono=True)
>>> Image.Overlay(img1, img2)
Image: 1280 x 960 (uint8), R:G:B
>>> Image.Overlay(img1, img2, 'rg')
Image: 1280 x 960 (uint8), R:G:B
>>> Image.Overlay(img1, img2, ((1, 0, 0), (0, 1, 0)))
Image: 1280 x 960 (uint8), R:G:B
Note:

Images can be different size, the output image size is the maximum of the dimensions of the input images. Small dimensions are zero padded. The top-left corner of both images are aligned.

Seealso:

anaglyph blend stshow