1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import numpy as np
import os
import sys
dir = os.path.split(os.path.realpath(__file__))[0]
sys.path.append(dir + '/..')
from tools import read_csv
color_map = read_csv(dir + '/ciexyz64_1.csv')
def map_wavelength(wavelength):
r = np.interp(wavelength, color_map[:,0], color_map[:,1])
g = np.interp(wavelength, color_map[:,0], color_map[:,2])
b = np.interp(wavelength, color_map[:,0], color_map[:,3])
if np.iterable(wavelength):
rgb = np.empty((len(wavelength),3))
rgb[:,0] = r
rgb[:,1] = g
rgb[:,2] = b
return rgb
else:
return np.array([r,g,b])
|