machinevisiontoolbox.Image.colorize

Image.colorize(color=[1, 1, 1], colororder='RGB', alpha=False)

Colorize a greyscale image

Parameters:
  • color (string, array_like(3)) – base color

  • colororder (str, dict) – order of color channels of resulting image

Returns:

color image

Return type:

Image instance

The greyscale image is colorized by setting each output pixel to the product of color and the input pixel value.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('shark1.png')
>>> img.colorize([1, 0, 0])  # red shark
Image: 500 x 500 (uint8), R:G:B
>>> img.colorize('blue')  # blue shark
Image: 500 x 500 (uint8), R:G:B
References:
  • Robotics, Vision & Control for Python, Section 11.3, P. Corke, Springer 2023.

Seealso:

mono