XYZ tristimulus values are mathematical abstractions, not physical reality. Moreover, the XYZ and xyY color spaces are not perceptually uniform; the relationships between closely-spaced colors are not intuitive. A number of color spaces, such as Lab, have been derived from XYZ that are of more practical use. Lab (formally, CIE L*a*b*) is a color-opponent space with dimensions L* for lightness and a* and b* for the color-opponent dimensions, based on nonlinearly transformed XYZ coordinates.
The lightness, L*, represents black at L* = 0, and white at L* = 100. The color channels, a* and b*, will represent neutral gray values at a* = 0 and b* = 0. The red/green opponent colors are represented along the a* axis, with a cyan-green at negative values and a magenta-red at positive values. The yellow/blue opponent colors are represented along the b* axis, with blue at negative values and yellow at positive values.
The intention of the Lab color space is to create a space that can be computed via simple formulas from the XYZ space but is more perceptually uniform than XYZ. The nonlinear relations for L*, a*, and b* are intended to mimic the nonlinear response of the eye.
When converting XYZ to Lab, the tristimulus values must be scaled from a reference white point. This means that Lab values, while device-indepdendent, represent the real-world appearance of a colored object viewed under an illuminant with the specified white point. Under illuminant D65, for example (which is the illuminant for sRGB), the normalized white point values are
The script converts Lab values to the sRGB color space via chromatic adaptation from a D50 working space, which is what popular photo editors use.
2000px-Lab_color_space.svg.png by Jacob Rus