|
![](/i/fill.gif) |
How can I convert spectral data to CIE XYZ components?
I calculate definite integral of spectrum multiplying spectrum values CIE
1931 color matching functions and then divide X, Y, Z -integrals with
(X+Y+Z). Then I calculate chromaticity coordinates from XYZ components and
compare these chromaticity coordinates to real chromaticity coordinates of
spectral data what I use to test code. My code gives wrong results and I
like to know what I do wrong.
I got spectral data with calculated chromaticity coordinates here:
http://www.cs.utah.edu/~bes/graphics/spectra/
And here is the critical part of code. cie_x, cie_y, cie_z and spectrum are
all natural splines.
---
#declare WaveLength = StartWaveLength;
#while (WaveLength <= EndWaveLength)
#declare X = X + cie_x(WaveLength) * spectrum(WaveLength);
#declare Y = Y + cie_y(WaveLength) * spectrum(WaveLength);
#declare Z = Z + cie_z(WaveLength) * spectrum(WaveLength);
* spectrum(WaveLength);
#declare WaveLength = WaveLength + 1;
#end
#declare xyz = X.x + Y.x + Z.x;
#declare X = X / xyz;
#declare Y = y / xyz;
#declare Z = Z / xyz;
---
Matti
Post a reply to this message
|
![](/i/fill.gif) |