Yxy到RGB转换 [英] Yxy to RGB conversion
问题描述
我正在尝试实现从Yxy颜色空间到RGB的转换方法。这是通过首先转换为XYZ而不是RGB来完成的。我发现Yxy的官方矩阵 - > XYZ是
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
这也是Matt Pharr的书物理基础中使用的那个渲染。
This is also the one used in Matt Pharr's book Physically Based Rendering.
另一方面,3D图形领域的许多人使用
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
现在,据我所知,如果x = 0.33333且y = 0.33333,Yxy会出现灰色阴影。这确实是我用第二个矩阵获得的。第一个创建一个红色RGB值。
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.
提前致谢
推荐答案
从xyY到XYZ的转换是非线性的,即它不能通过矩阵乘法计算。
来自维基百科的 CIE 1931色彩空间:
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 )
您的矩阵似乎都是针对XYZ到RGB的转换。第一个由sRGB初选和白点给出。第二个由初选非常接近sRGB(绿色 x = 0.29
, y = 0.60
)和 x = 0.334
, y = 0.334
白点。
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.
如果你希望使用其他RGB原色和白点,有一个列表: http://brucelindbloom.com /index.html?Eqn_RGB_XYZ_Matrix.html
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
这篇关于Yxy到RGB转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!