Search code examples
colorscomputer-visionrgb

What is the relationship between color space RGB, XYZ and the color matching function?


What is the relationship between color spaces (RGB, XYZ) and the color matching function? Let's say we have some color matching function in the color space XYZ (3 row matrix). We also have the transformation matrix which translates from XYZ coordinates to RGB coordinates.

My understanding is that there is some visual input, which is made up of the color spectrum S(y). The human eye does not see the world - it only sees its interpretation of the world. The human eye has 3 cone types LMS, each of which is responsible for processing RED, GREEN, or BLUE. The human eye sees the spectral color only because it's eye sums over RED, GREEN, BLUE vector, and this sum matches the color of the input. In order to match the color, there is a color matching function, which takes the input spectrum and produces the weights by which to multiply the primary RED, GREEN, BLUE color vector. These then get added and their output visually matches the spectral input, even though the spectrum had many many frequencies added, while the human eye was only adding 3. So we went from HUGE space to space where we can describe all with 3 vectors, summed as dictated by the color matching function.

The spectral input, color primaries, and color matching functions behave as described above and can be summarized in this formula:

how primary color is summed with weights produced by the color matching function

where pi is the 3d vector of primary colors, c - color matching function is also a vector of 3 components, and finally s is the spectral input.

We have XYZ color space, and a corresponding color matching function which does what is described above. We are then given matrix T, which transforms XYZ coordinates to RGB coordinates. We already know T, and we need to use it to produce a new color matching function for the RGB color space.

I do not understand how the color space relates to choice of primaries pi(λ) and the choice of color functions ci(λ1).


Solution

  • I think lots of issues with color selection are due technical problems people had to solve. Usually you are not trying to reproduce colors as accurately as possible, but to make them pleasant looking, cheap, fast to calculate on cpu.... If someone watches plains of New Zealand on TV he is very unlikely to know they really look like, but almost certainly wants to enjoy the picture and pay little for it.

    Several reasons why you might want to use different color matching functions might include:

    • You are taking pictures under non-white light and you want your picture to look natural.
    • You are taking underwater pictures and want to compensate for the fact that water attenuates different frequencies at different speeds.
    • Your sensor is not perfect and you want to compensate for that.

    On the other hand you might want to change your primaries due to some reason. For example your images might be taking a picture of a scene with limited amount of colors. By nudging your primaries a little you might get a "fuller" picture.

    Finally sometimes you just have to compensate for some of the limitations you have with your devices. Your phosphorus on CRT TV will impose some restrictions. So will the noise in air when transmitting using PAL. On the other hand if you go digital you might be forced to have less than 36 bits per pixel. In that case you will have to make compromises and this will give you opportunity to lose as little as possible.

    If you want a short tutorial visit Cambridge in colour.

    Here is a Szeliski's textbook on photography, look at chapters 1 2 and 10.

    Poyton has list of common transformations.