summaryrefslogtreecommitdiff
path: root/chromaticity.py
blob: 18ec28ff86e8870a6908cf2d3ff88092e7048373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import numpy as np

f = open('ciexyz64_1.csv')

color_map = []
for line in f:
    color_map.append([float(s) for s in line.split(',')])

f.close()

color_map = np.array(color_map)

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

    return r, g, b