如何在PHP中将CIE颜色空间转换为RGB或HEX颜色代码 [英] How to convert CIE color space into RGB or HEX color code in PHP
本文介绍了如何在PHP中将CIE颜色空间转换为RGB或HEX颜色代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在某个Web应用程序上工作,我想将CIE 1931颜色空间代码转换为RGB或HEX代码.如何转换?
I`m working on some web application where I want to convert CIE 1931 color space code to RGB or HEX code. How can I convert it?
推荐答案
好,要从XYZ转换为RGB,可以使用以下矩阵:
Well, to get to RGB from XYZ you can use this matrix:
[ R ] [ 3.240479 -1.537150 -0.498535 ] [ X ]
[ G ] = [ -0.969256 1.875992 0.041556 ] * [ Y ]
[ B ] [ 0.055648 -0.204043 1.057311 ] [ Z ]
但是由于您具有xyY(至少,我认为)值,因此您首先需要将它们转换为XYZ值,如下所示:
But since you have xyY (at least, I assume) values, you'll first need to convert them to XYZ values, like so:
X = (x*Y)/y
Y = Y
Z = ((1-x-y)*Y)/y
因此,从理论上讲,您可以这样计算:
So in theory, you could calculate it like so:
R = 3.240479*((x*Y)/y) + -1.537150*Y + -0.498535*(((1-x-y)*Y)/y)
G = -0.969256*((x*Y)/y) + 1.875992*Y + 0.041556*(((1-x-y)*Y)/y)
B = 0.055648*((x*Y)/y) + -0.204043*Y + 1.057311*(((1-x-y)*Y)/y)
这篇关于如何在PHP中将CIE颜色空间转换为RGB或HEX颜色代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文