So fmw42 or who is the author of the code has to have some function to convert the colors to 3D space.. I have read a pdf file
http://www.google.cz/url?q=http://www.f ... uGS5C3lHtg
3. RGB Color-Matching Functions
4. XYZ Coordinates
5. XYZ Primaries
6. XYZ Color-Matching Functions
7. Chromaticity Values
8. Color Space Visualization
9. Color Temperature and White Points
10. CIE RGB Gamut in xyY
11. Color Space Calculations
...
27 Appendix A Color Matching
29 Appendix B Further Explanations for Chapter 5
30 CIE Color Space
There are some formulas but not sure if it is relative with the topic. E.g. page 30 contains apendix about Photometric luminance, there are come convertions already build-in but I don't belive this is what IM uses in his convertion functions.
(I will likely delete this citation later becasue it is long and out of topic)
Appendix B Further Explanations for Chapter 5
Chapter 5 has always been enigmatic - since the beginning about ten years ago .
Now I am very grateful to Monsieur Jean-Yves Chasle for giving further explanations, here posted un-changed.
Photometric luminance of color (page 4)
The CIE Photopic Luminous Efficiency function V is related to r_bar, g_bar and b_bar:
V(?) = 1.0000*r_bar(?) + 4.5907*g_bar(?) + 0.0601*b_bar(?) (1)
The theorical light efficacy k equals 683 lm/W, based on the luminous flux measured at around 555 nm where
V(?) equals 1. As on page 4, considering a light with a spectral power diffusion P
in W/sr.m2, the photometric luminance (in cd/m2) can be calculated as:
L = k*integral{P(?)*V(?)*d?} (2)
where k is the efficacy of the source light.
Substituting (1) in (2):
L = k*integral{P(?)*(1.0000*r_bar(?) + 4.5907*g_bar(?) + 0.0601*b_bar(?))*d?}
= 1.0000*k*integral{P(?)*r_bar(?)*d?} + 4.5907*k*integral{P(?)*g_bar(?)*d?} +
0.0601*k*integral{P(?)*b_bar(?)*d?}
Using notations from page 4 (in cd/m2):
L = 1.0000*R + 4.5907*G + 0.0601*B (3)
in cd/m2.
The photometric luminance (in cd/m2) can be separated in terms of tristimulus values Lr, Lg and Lb:
Lr = 1.0000*R (4)
Lg = 4.5907*G (5)
Lb = 0.0601*B (6)
Lr, Lg and Lb represent the photometric luminance (in cd/m2) at each wavelength (700, 546.1 and 435.8 respectively). These luminances are reported on the graph named „R,G,B“ on page 4 and 6 for a matched white light of coordinates (1,1,1) in the CIE RGB space. In practice, the light efficacy k is less than 683 lm/W. In [1], Hunt publishes samples of this value depending on the light type (page 75-79, and table 4.2 page 97).
Application (page 6)
These results can be applied on page 6, where X = 1, Y = 0 and Z = 0 representing X in the CIE XYZ space is converted to the CIE RGB space in order to evaluate its photometric luminance at each wavelength (700, 546.1 and 435.8 respectively):
R = +2.36461*X - 0.89654*Y - 0.46807*Z = +2.36461
G = -0.51517*X + 1.42641*Y + 0.08876*Z = -0.51517
B = +0.00520*X - 0.01441*Y + 1.00920*Z = +0.00520
in colorimetric luminance of red, green and blue.
From (4), (5) and (6):
Lr = 1.0000*R = 1.0000 * +2.36461 = +2.36461
Lg = 4.5907*G = 4.5907 * -0.51517 = -2.36499
Lb = 0.0601*B = 0.0601 * +0.00520 = +0.00031
(in cd/m2)
These luminances are reported on the graph named „X“ on page 6. Using (3), they sum to 0 as expected. Same calculations for Y and Z, leading to the graphs named „Y“ and „Z“ on page 6.
PS:
I believe if you want to convert colors to 3D space you need to convert to x,y coordinates. But I did not understand how to do this convertion from the pdf description. Not enough examples.
Much more interesting is page 24 which ScreenShot I paste here (I can change it to link if admin wishes):
So I think I understand how they calculate the colors but not how the convert from RGB to xyY and from xyY to RGB (I am not sure if I say this right, is it xyY namespace?).