3

OpenCV中的颜色查找表LUT

 2 years ago
source link: https://xugaoxiang.com/2022/07/09/opencv-lut/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

LUTLook Up Table 查找表,它是一种 像素值映射表,主要是用来增强图像的对比度。

20025407eb1e98d2.png

由上图中可以看到

  • 原图中像素值为40的像素,经过查找表映射后值变为90
  • 原图中像素值为30的像素,经过查找表映射后值变为10

经过变换后,就会得到一张对比度变高的图像。

OpenCVapplyColorMap(src, dst, COLORMAP) 可以实现图像的彩色变换

其中参数:

  • src 表示输入图像
  • dst表示输出图像
  • 颜色LUT, OpenCV支持22种颜色风格的查找表映射
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

最后看个示例

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()

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK