machinevisiontoolbox.Image.gamma_decode

Image.gamma_decode(gamma)

Gamma decoding

Parameters:

gamma – gamma value

Returns:

gamma decoded version of image

Return type:

Image instance

Gamma decode the image. This takes a gamma-encoded image, as typically obtained from a camera or image file, and converts it to a linear luminance image. gamma is either the string ‘sRGB’ for IEC 61966-2-1:1999 or a float:

\[\mat{Y}_{u,v} = \mat{X}_{u,v}^\gamma\]

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Read('street.png')
>>> linear = img.gamma_decode('sRGB')
Note:
  • gamma is the reciprocal of the value used for gamma encoding

  • Gamma decoding should be applied to any color image prior to colometric operations.

  • Gamma decoding is typically performed in the display hardware with \(\gamma=2.2\).

  • For images with multiple planes, the gamma decoding is applied to all planes.

  • For floating point images, the pixels are assumed to be in the range 0 to 1.

  • For integer images,the pixels are assumed in the range 0 to the maximum value of their class. Pixels are converted first to double, processed, then converted back to the integer class.

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

Seealso:

gamma_encode colorspace