Image.Overlay#

classmethod Image.Overlay(im1: Image, im2: Image, colors: str = 'rc') Self[source]#

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(size=(1280, 960), dtype=uint8, nplanes=3, colororder=R:G:B)
>>> Image.Overlay(img1, img2, 'rg')
Image(size=(1280, 960), dtype=uint8, nplanes=3, colororder=R:G:B)
>>> Image.Overlay(img1, img2, ((1, 0, 0), (0, 1, 0)))
Image(size=(1280, 960), dtype=uint8, nplanes=3, colororder=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