machinevisiontoolbox.Image.LUT

Image.LUT(lut, colororder=None)

Apply lookup table

Parameters:
  • lut (array_like(256), ndarray(256,N)) – lookup table

  • colororder (str or dict) – colororder for output image, optional

Returns:

transformed image

Return type:

Image

For a greyscale image the LUT can be:

  • (256,)

  • (256,N) in which case the resulting image has N planes created my applying the I’th column of the LUT to the input image

For a color image the LUT can be:

  • (256,) and applied to every plane, or

  • (256,N) where the LUT columns are applied to the N planes of the input image.

Example:

>>> from machinevisiontoolbox import Image
>>> import numpy as np
>>> img = Image([[100, 150], [200, 250]])
>>> img.LUT(np.arange(255, -1, -1, dtype='uint8')).A
array([[155, 105],
       [ 55,   5]], dtype=uint8)
Note:

Works only for uint8 and int8 image and LUT.

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

Seealso:

cv2.LUT