Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yxy to RGB conversion

I am trying to implement a conversion method from Yxy color space to RGB. This is done by first converting to XYZ and than to RGB. I found out that the "official" matrix for Yxy -> XYZ is

3.2410 -1.5374 -0.4986

-0.9692 1.8760 0.0416 

0.0556 -0.2040 1.0570 

This is also the one used in Matt Pharr's book Physically Based Rendering.

On the other hand, many people in 3D graphics area use

2.5651-1.1665 -0.3986

-1.0217 1.9777 0.0439

0.0753 -0.2543 1.1892

Now, as far as I understand if x= 0.33333 and y=0.33333, Yxy gives a gray shade. This is indeed what I obtain with the second matrix. The first one creates a red RGB value.

The second matrix works but where does it come from? I find many people using it in their example codes but nobody really explains if it has a physical background.

Thanks in advance

like image 492
converter Avatar asked Oct 28 '25 08:10

converter


1 Answers

The conversion from xyY to XYZ is non-linear, i.e. it cannot be computed by a matrix multiplication. From the Wikipedia on the CIE 1931 color space:

X = Y / y * x
Z = Y / y * ( 1 - x - y )

Both your matrices seem to be for the XYZ to RGB conversion. The first given by the sRGB primaries and white point. The second by primaries very close to sRGB (green has x = 0.29, y = 0.60) and a x = 0.334, y = 0.334 white point.

If you wish to use other RGB primaries and white point, there is a list at: http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html

like image 135
Mats Avatar answered Oct 30 '25 15:10

Mats