#include <ColourSystem.h>
The colour mapping is specified by the (x,y) chromaticities of the three primary colours of the system, and the chromaticity and luminance of the system's white point. (From this, the luminances of the primaries can be derived.) See Foley & van Dam, p586.
See ColourSystem.h for various predefined colours systems and illuminants.
Sources: http://www.inforamp.net/~poynton/ColorFAQ.html, http://www.efg2.com/lab/Graphics/Colors/Chromaticity.htm
Notes.
CIE Y matches the eye's spectral efficiency curve thus it measures the colour's *luminance*, in candela.
X and Z are orthogonal to luminance; varying them does not affect the luminance (or perceived brightness) of the colour, just its hue.
We can find the luminance of an RGB colour by simply transforming it back to XYZ space, and then taking the Y component. Thus if w = toXYZ[1], then dot(w, clr) is clr's luminance. The Luminance() method is provided for this.
To convert a chrominance/luminance (x, y, Y) specification into an XYZ colour requires:
form XYZ corresponding to x, y clr = [x, y, 1.0 - y - x] normalise to a luminance of 1.0 clr /= y; multiply through by luminance clr *= Y;
Beware: converting a (say) unit luminance chroma to RGB will give you colours that are equally perceptually bright. This may not be what you want: if you try to display such a range of chromas, for instance, the white point will get mapped to [1, 1, 1], but bluish hues will be mapped so that the blue component is much bigger than 1, because of our relative insensitivity to blue.
In such cases, you probably want the brightest-possible device colour corresponding to each specified chroma, so...
form XYZ corresponding to x, y clr = [x, y, 1.0 - y - x] convert to RGB clr = cs.XYZToGamut(clr); normalise to brightest possible RGB clr /= MaxCmpt(clr);
Definition at line 21 of file ColourSystem.h.
Definition at line 74 of file ColourSystem.cc.
Returns true if the colour can't be represented by this device.
Definition at line 173 of file ColourSystem.cc.
Convert CIE chromaticity to colour system colour of unit luminance.
Definition at line 158 of file ColourSystem.cc.
Returns true if the colour can't be represented by this device.
Definition at line 168 of file ColourSystem.cc.
Convert CIE XYZ colour to device colour, and constrain the result to be within its gamut.
Transform from CIE XYZ space to the colour system's space (usually RGB), and saturate it to keep it within the system's gamut if necessary.
The version of this at http://www.fourmilab.ch/documents/specrend is buggy -- its choice of clip axis can be wrong.
Definition at line 112 of file ColourSystem.cc.
Definition at line 62 of file ColourSystem.h.
Definition at line 66 of file ColourSystem.h.
Definition at line 67 of file ColourSystem.h.
Definition at line 68 of file ColourSystem.h.
Definition at line 61 of file ColourSystem.h.
Definition at line 69 of file ColourSystem.h.
Definition at line 70 of file ColourSystem.h.