XYZ Color Space

This color model is based on three hypothetical primaries, XYZ. All visible colors can be represented by using only positive values of X, Y, and Z. The Y primary match closely to luminance, while X and Z primaries give color information.

An RGB matrix color space is defined by specifying the XYZ coordinates for five colors, those being the color space’s:

  1. Darkest dark color (Black)
  2. Lightest light color (White)
  3. Reddest red color
  4. Greenest green color
  5. Bluest blue color

The XYZ coordinates for the reddest possible red, greenest possible green and bluest possible blue are called the color space’s Red, Green, and Blue primaries. In other words it only takes five XYZ coordinates to define an RGB matrix color space, those are the XYZ coordinates for the five RGB colors black, red, blue, green, and white. However, the resulting shape in XYZ space isn’t a pyramid (5 vertices, 4 sides), but rather a hexahedron (8 vertices, 6 sides), with the following eight XYZ coordinates as vertices:

  1. Black
  2. White
  3. Red
  4. Green
  5. Blue
  6. Magenta
  7. Yellow
  8. Cyan

We can get 8 XYZ vertices by specifying only five XYZ coordinates since light is additive. So once you know the XYZ locations of the red, blue, and green primaries, add red and blue to get magenta, add red and green to get yellow, and add blue and green to get cyan.

Reference White

D65 corresponds roughly to the average midday light in Western Europe / Northern Europe, hence it is also called a daylight illuminant. D65 is intended to represent average daylight and has a correlated colour temperature of approximately 6500 K. Saying a color is “white” means you’ve already picked a particular “color of white” to act as your reference white. If D50 is your reference white, then D65 is actually blue. If D65 is your reference white, the D50 is actually yellow. If you change your reference white, you have to change all the colors or they look funny.


Given an XYZ color whose components are in the nominal range [0.0, 1.0] and whose reference white is the same as that of the RGB system, the conversion to companded RGB is done in two steps.

  1. Convert XYZ to Linear RGB
  2. Linear RGB channels (denoted with lower case (r,g,b), or generically v) are made nonlinear (denoted with upper case (R,G,B) or generically V). This operation is performed on all three channels, but the operation depends on the companding function (for example applying Gamma) associated with the RGB color system.


A companded RGB color [RGB], whose components are in the nominal range [0, 1], is converted to XYZ in two steps.

  1. First, the companded RGB channels (denoted with upper case (R,G,B)) are made linear with respect to energy (denoted with lower case (r,g,b)). This same operation is performed on all three channels, but the operation depends on the companding function associated with the RGB color system.
  2. Linear RGB to XYZ


  1. XYZ to RGB
  2. RGB to XYZ