Reprinting From https://blog.csdn.net/JNingWei/article/details/78803669

ColorMap(色度图)

在图像处理中,伪色彩用途广泛。假设我们想在地图上显示我国夏天不同地区的温度, 由于温度是单值, 如果通过灰度图来表示, 不直观. 这时候可以通过使用伪色彩么模式来显示, 给人更直观的感受, 如红色表示较高高温, 蓝色表示较低温度.温度数据只是一个例子,还有很多其他数据如(高度、压力、密度、湿度)是单值(灰度)的情况,将其转换为彩色数据以实现可视化是有意义的。

HeatMap-LMLPHP

OpenCV 定义了 13 种 ColorMap,可以应用于灰度图像,使用函数 applyColorMap 可以将将灰度图转化为彩色图(伪色彩图像). ColorMap中的 COLORMAP_JET模式,就常被用于生成我们常见的热力图.

Syntax

import cv2
# COLORMAP_AUTUMN = 0,
# COLORMAP_BONE = 1,
# COLORMAP_JET = 2,
# COLORMAP_WINTER = 3,
# COLORMAP_RAINBOW = 4,
# COLORMAP_OCEAN = 5,
# COLORMAP_SUMMER = 6,
# COLORMAP_SPRING = 7,
# COLORMAP_COOL = 8,
# COLORMAP_HSV = 9,
# COLORMAP_PINK = 10,
# COLORMAP_HOT = 11 img = cv2.imread("girl.jpg")
for i in range(0, 13):
im_color = cv2.applyColorMap(img, i)
cv2.imwrite("{}.jpg".format(i), im_color)

原图

HeatMap-LMLPHP

伪色彩图

COLORMAP_AUTUMN = 0

HeatMap-LMLPHP

COLORMAP_BONE = 1

HeatMap-LMLPHP

COLORMAP_JET = 2

HeatMap-LMLPHP

COLORMAP_WINTER = 3:

HeatMap-LMLPHP

COLORMAP_RAINBOW = 4

HeatMap-LMLPHP

COLORMAP_OCEAN = 5

HeatMap-LMLPHP

COLORMAP_SUMMER = 6

HeatMap-LMLPHP

COLORMAP_SPRING = 7

HeatMap-LMLPHP

COLORMAP_COOL = 8

HeatMap-LMLPHP

COLORMAP_HSV = 9

HeatMap-LMLPHP

COLORMAP_PINK = 10

HeatMap-LMLPHP

COLORMAP_HOT = 11

HeatMap-LMLPHP

COLORMAP_PARULA=12

HeatMap-LMLPHP



04-16 00:24