Color Lookup Table LUT in OpenCV

LUT is the Look Up Table , which is a pixel value mapping table , mainly used to enhance the contrast of the image.

It can be seen from the figure above

  • The pixel with the pixel value of 40 in the original image, after the lookup table mapping, the value becomes 90
  • The pixel with the pixel value of 30 in the original image, after the lookup table mapping, the value becomes 10

After the transformation, an image with high contrast will be obtained.

applyColorMap(src, dst, COLORMAP) in OpenCV can realize color transformation of images

Among the parameters:

  • src represents the input image
  • dst represents the output image
  • Color LUT, OpenCV supports lookup table mapping of 22 color styles
 COLORMAP_AUTUMN: int COLORMAP_BONE: int COLORMAP_CIVIDIS: int COLORMAP_COOL: int COLORMAP_DEEPGREEN: int COLORMAP_HOT: int COLORMAP_HSV: int COLORMAP_INFERNO: int COLORMAP_JET: int COLORMAP_MAGMA: int COLORMAP_OCEAN: int COLORMAP_PARULA: int COLORMAP_PINK: int COLORMAP_PLASMA: int COLORMAP_RAINBOW: int COLORMAP_SPRING: int COLORMAP_SUMMER: int COLORMAP_TURBO: int COLORMAP_TWILIGHT: int COLORMAP_TWILIGHT_SHIFTED: int COLORMAP_VIRIDIS: int COLORMAP_WINTER: int

A final example

 import cv2 image = cv2.imread('lenna.png') cv2.imshow('original image', image) # 变换到深绿色dst = cv2.applyColorMap(image, cv2.COLORMAP_DEEPGREEN) cv2.imshow('dst image', dst) cv2.waitKey(0) cv2.destroyAllWindows()

This article is reprinted from https://xugaoxiang.com/2022/07/09/opencv-lut/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment