1
votes

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
which color space exactly do you want to convert? Is it RGB? or XYZ? or xyY?Tularis
I want to convert CIE color space which is in XY to RGBRaj Sf

1 Answers

0
votes

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)