diff --git a/lib/blending.hpp b/lib/blending.hpp index c481c674f..a8516fee5 100644 --- a/lib/blending.hpp +++ b/lib/blending.hpp @@ -23,21 +23,21 @@ #include #include -static const float T_MATRIX_SMALL[3][NUM_WAVES] = {{0.004727862039458, 0.082644899379487, -0.322515894576622, -0.064320292139570, -1.064746457514018, 0.288869101686002, 0.010454417702711}, -{-0.004081870492374, -0.101308479809214, 0.320514309815141, 0.720325047228787, -0.066431970334792, -0.028358642287937, -0.001135818542699}, -{0.028683360043884, 1.054907349924059, 0.116111201474362, -0.084435897516297, --0.029621508810678, -0.002318568718824, -0.000070180490104}}; +static const float T_MATRIX_SMALL[3][NUM_WAVES] = {{0.088688384631047, -0.033324923719516, -0.002151997579192, + -0.007051952965538, -0.632215054562246, 1.382222884885893, 0.103544620506161}, + {-0.079153682170459, -0.004289508134047, 0.001818332974765, 0.008633447437121, + 1.220255539120574, -0.103597442877585, -0.011093719072566}, + {0.568628558510617, 0.525725695518964, 0.002166526642066, 0.000067954428273, + -0.108086836427399, -0.015075717909452, -0.000714640619377}}; -static const float spectral_r_small[NUM_WAVES] = {.014976989831103, 0.015163469993149, 0.024828861915840, 0.055372724024590, -0.311175941451513, 2.261540004074889, 2.451861959778458}; +static const float spectral_r_small[NUM_WAVES] = {0.015118827139972, 0.018244753356220, 0.028028111807405, 0.043179460050345, + 0.067154869563762, 0.686709823363608, 0.897219406952636}; -static const float spectral_g_small[NUM_WAVES] = {0.060871084436057, 0.063645032450431, 0.344088900200936, 1.235198096662594, -0.145221682434442, 0.101106655125270, 0.099848117829856}; +static const float spectral_g_small[NUM_WAVES] = {0.075714499304728, 0.104056445141605, 0.210008756476146, 0.424904304806374, + 0.855639860506995, 0.365637159759551, 0.345332969547009}; -static const float spectral_b_small[NUM_WAVES] = {0.777465337464873, 0.899749264722067, 0.258544195013949, 0.015623896354842, -0.004846585772726, 0.003989003708280, 0.003962407615164}; +static const float spectral_b_small[NUM_WAVES] = {0.816231569276521, 1.024805860576951, 1.024805685467384, 1.024803703202828, + 0.047862925501399, 0.001000080038470, 0.001000000000000}; /* The sum of all channel coefficients - this _should be_ a compile-time diff --git a/lib/color.py b/lib/color.py index 4f23a0fda..d9897d3a0 100644 --- a/lib/color.py +++ b/lib/color.py @@ -1647,20 +1647,14 @@ def RGB_to_Spectral(rgb): # target_XYZ = np.sum([r, g, b] * RGB_to_XYZ_m, axis=1) # spd = XYZ_to_spectral(target_XYZ, cmfs=CMFS.align(shape), illuminant=illuminant_SPD, interval=interval, tolerance=tol, max_refl=max_refl) - spectral_r = r * np.array([.014976989831103, 0.015163469993149, - 0.024828861915840, 0.055372724024590, - 0.311175941451513, 2.261540004074889, - 2.451861959778458], dtype='float32') + spectral_r = r * np.array([0.015118827139972, 0.018244753356220, 0.028028111807405, 0.043179460050345, + 0.067154869563762, 0.686709823363608, 0.897219406952636], dtype='float32') - spectral_g = g * np.array([0.060871084436057, 0.063645032450431, - 0.344088900200936, 1.235198096662594, - 0.145221682434442, 0.101106655125270, - 0.099848117829856], dtype='float32') + spectral_g = g * np.array([0.075714499304728, 0.104056445141605, 0.210008756476146, 0.424904304806374, + 0.855639860506995, 0.365637159759551, 0.345332969547009], dtype='float32') - spectral_b = b * np.array([0.777465337464873, 0.899749264722067, - 0.258544195013949, 0.015623896354842, - 0.004846585772726, 0.003989003708280, - 0.003962407615164], dtype='float32') + spectral_b = b * np.array([0.816231569276521, 1.024805860576951, 1.024805685467384, 1.024803703202828, + 0.047862925501399, 0.001000080038470, 0.001000000000000], dtype='float32') # return np.log2(np.array(spd.values, dtype='float32')) return np.log2(np.sum([spectral_r, spectral_g, spectral_b], axis=0)) @@ -1671,18 +1665,12 @@ def Spectral_to_RGB(spd): """ # Spectral_to_XYZ CMFS premultiplied with XYZ to RGB matrix - T_MATRIX = (np.array([[0.004727862039458, 0.082644899379487, - -0.322515894576622, -0.064320292139570, - 1.064746457514018, 0.288869101686002, - 0.010454417702711], - [-0.004081870492374, -0.101308479809214, - 0.320514309815141, 0.720325047228787, - 0.066431970334792, -0.028358642287937, - -0.001135818542699], - [0.028683360043884, 1.054907349924059, - 0.116111201474362, -0.084435897516297, - -0.029621508810678, -0.002318568718824, - -0.000070180490104]], dtype='float32')) + T_MATRIX = (np.array([[0.088688384631047, -0.033324923719516, -0.002151997579192, + -0.007051952965538, -0.632215054562246, 1.382222884885893, 0.103544620506161], + [-0.079153682170459, -0.004289508134047, 0.001818332974765, 0.008633447437121, + 1.220255539120574, -0.103597442877585, -0.011093719072566], + [0.568628558510617, 0.525725695518964, 0.002166526642066, 0.000067954428273, + -0.108086836427399, -0.015075717909452, -0.000714640619377]], dtype='float32')) r, g, b = np.sum(np.exp2(spd) * T_MATRIX, axis=1) return r, g, b