Color management is based on XYZ tristimulus values. X, Y, and Z are mathematical pseudo-colors analogous to the three types of cone cells of the human eye, which are sensitive to long, middle, and short wavelengths. One way to think of X, Y, and Z is “sort of like red,” “sort of like green,” and “sort of like blue.” Three parameters like this can in principle describe any color sensation. The color-matching functions that define the response of the X, Y, and Z “receptors” are known as the CIE standard observer.
The CIE XYZ color space is device-independent, and encompasses all color sensations that an average person can experience. But not all XYZ combinations correspond to real colors that can be physically produced by spectral distributions of light.
Tristimulus values are converted to real RGB colors via a 3×3 matrix and gamma correction, or a lookup table (LUT) in the case of complex color profiles. The white point of the RGB color space is implicit in the transformation. This script converts XYZ values to the sRGB color space, which web browsers use by specification. Out-of-gamut colors are noted. Larger color spaces would have larger gamuts; the accuracy of their representation would depend on the gamut of the display device used to view them. The matrix and gamma function for sRGB:
where a = 0.055
287px-Cones_SMJ2_E.svg.png by Vanessaezekowitz at en.wikipedia, CC BY-SA 3.0,
325px-CIE_1931_XYZ_Color_Matching_Functions.svg.png by User:Acdx - Own work, GFDL,