我在<-a, b>
范围内有2d值的矩阵。我想用灰度图像来显示这个图像。我应该如何处理我的数据以正确地将其可视化?
据我所知,人眼具有对数刻度,所以我的转换也应该是对数的。
在感知上均匀的颜色空间中将您的值转换为亮度,例如CIE Lab或Luv。然后从那里转换为RGB进行显示。
例如,这些在colormath模块中可用。
如果您的输入值是x
L = 100*(x - xmin) / (xmax - xmin) # L is 0-100
a, b = 0, 0 # neutral values
from colormath.color_objects import LabColor, RGBColor
from colormath.color_conversions import convert_color
lab = LabColor(L, a, b)
rgb = convert_color(lab, RGBColor)
# display rgb
Matplotlib在colormaps部分有很多关于此的信息: https://matplotlib.org/users/colormaps.html