Image.colorize#

Image.colorize(color=[1, 1, 1], colororder: str = 'RGB', alpha: bool | float = False) Self[source]#

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(size=(500, 500), dtype=uint8, nplanes=3, colororder=R:G:B)
>>> img.colorize('blue')  # blue shark
Image(size=(500, 500), dtype=uint8, nplanes=3, colororder=R:G:B)
References:
Seealso:

mono