How does one properly scale an XYZ color gamut bounding volume after computing it from color matching functions?

817 views Asked by At

After computing the XYZ gamut bounding mesh below from spectral samples/color matching functions, how does one scale the resulting volume for compatibility with popular color spaces such as sRGB? More specifically, the size and scale of the volume depends on the number of samples and the integral approximation method used to compute it. How, then, can one determine the right values to scale such volumes to match known color spaces like sRGB, P3-Display, NTSC, PAL, etc?

oddly scaled CIE XYZ color gamut bounding volume.

It seemed like fitting the whole volume so that Y ranges from [0, 1] would work, but it had several problems:

  1. When compared to a sub-volume generated by converting the sRGB color cube to XYZ space, the result protruded outside of the 'full gamut'.sRGB->XYZ volume protruding beyond the XYZ full gamut.
  2. Converting random XYZ values from the full gamut volume to sRGB and back, the final XYZ doesn't match the initial one.

Most (all?) standardized color spaces derive from CIE XYZ, so each must have some kind of function or transformation to and from the full XYZ Gamut, or at least each must have some unique parameters for a general function.

How does one determine the correct function and its parameters?

2

There are 2 answers

5
Ben McKenneby On

Further research and experimentation implied that the XYZ volume should scale such that { max(X), max(Y), max(Z) } should equal the illuminant from the working space. In the case of sRGB, that illuminant (also called white point) is called D65.

Results look convincing, but expert confirmation would still be appreciated.

enter image description here

17
Myndex On

Short answer

If I understand your question, you are trying to accomplish is determining the sRGB gamut limits (boundary) relative to the XYZ space you have constructed.

Longer answer

I am assuming you are NOT trying to accomplish gamut mapping. This is non-trivial, and there are multiple methods (perceptual, absolute, relative, etc). I'm going to set gamut mapping aside, and instead focus on determining how some arbitrary color space fints inside your XYZ volume.

First to answer your granular questions:

After computing the XYZ gamut bounding mesh below from spectral samples, how does one scale the volume for compatibility with popular color spaces such as sRGB?

What spectral samples? From a spectrophotometer reading a test print under a given standard illuminant? Or where did they come from? A color matching experiment?

The math is a matter of integrating the spectral data to form the XYZ space, which you apparently have done. What illuminant (white point)??

It seemed like fitting the whole volume so that Y ranges from [0, 1] would work, but it had several problems:

Whole volume of what? The sRGB space? How did you convert the sRGB data to YXZ? OR is this really the question you are asking?

What are the proper scaling constants?

They depend on the spectral data and the adapted white point for the spectral data. sRGB is D65. Most printing is done using D50.

Does each color space have its own ranges for x, y, and z values? How can I determine them?

YES.

Every color space has a different transformation matrix depending on the coordinates of the R G and B primaries. The primaries can be imaginary, such as in ProPhoto.

Some Things

The math you are looking for you can find at brucelindbloom.com and also, you might want to check out Thomas Mansencal's ColorScience, a python library that's the swiss-army-knife of color.

sRGB

XYZ is a linear light space, wherein Y = 0.2 to Y = 0.4 is a doubling of luminance.

sRGB is not a linear space, there is a gamma curve or tone response curve on sRGB data, such that rgb(20,20,20) to rgb(40,40,40) is NOT a doubling of luminance.

The first thing that needs to be done is linearize the sRGB color data.

Then take the linear RGB and run it through the appropriate matrix. If the XYZ data is relative to a different adapting white point, then you need to do something like a Bradford transform to convert to the appropriate one for your XYZ space.

The Bruce Lindbloom site has some ready-to-go matrixes for a couple common situations.

The problem you are describing can be caused by either (or both) failing to linearize the sRGB data and/or not adapting the white point. And... possibly other factors.

If you can answer my questions regarding the source of the spectral data I can better assist.