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?
1条回答 默认 最新
- duanhao4909 2014-02-05 20:49关注
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 ]
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)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报