machinevisiontoolbox.Image.mono

Image.mono(opt='r601')

Convert color image to monochrome

Parameters:

opt (str, optional) – greyscale conversion mode, one of: ‘r601’ [default], ‘r709’, ‘value’ or ‘cv’

Returns:

monochrome image

Return type:

Image

Return a greyscale image of the same width and height as the color image. Various conversion options are available:

opt

definition

'r601'

ITU Rec. 601, Y’ = 0.229 R’ + 0.587 G’ + 0.114 B’

'r709'

ITU Rec. 709, Y’ = 0.2126 R’ + 0.7152 G’ + 0.0722 B’

'value'

V (value) component of HSV space

'cv'

OpenCV colorspace() RGB to gray conversion

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('flowers1.png')
>>> img
Image: 640 x 426 (uint8), R:G:B [.../images/flowers1.png]
>>> img.mono()
Image: 640 x 426 (uint8)
Note:

For a monochrome image returns a reference to the Image instance.

References:
  • Robotics, Vision & Control for Python, Section 10.2.7, P. Corke, Springer 2023.

Seealso:

colorspace colorize