does anyone have a good working conversion matrix from RGB colors to Hue CIE colors

455 views
Skip to first unread message

Dale Schultz

unread,
Apr 22, 2014, 10:01:13 PM4/22/14
to hue-h...@googlegroups.com
I am amazed that Philips does not publish any data on how to convert RGB colors to their xy values.

I have codes a conversion matrix and its reverse but the values are not quite correct so I am looking for the correct matrix that is used.

I also battled to make the reverse conversion (xy to RGB) so that I could pick up the current values from the bridge and show the same colors on the computer.
Eventually I converted every RGB value to my (poor) xy value to 2 decimals places and I use that to construct a look-up table to convert back to RGB, but I would rather get a proper matrix formula in order to round trip the color values properly.




huefan

unread,
Apr 23, 2014, 12:23:00 PM4/23/14
to hue-h...@googlegroups.com
Did you take a look at the applicationnote in the iOS SDK?

https://github.com/PhilipsHue/PhilipsHueSDK-iOS-OSX/blob/master/ApplicationDesignNotes/RGB%20to%20xy%20Color%20conversion.md

It decribes the conversion from xy to rgb and the other way around.

I have ported the iOS code for xy-to-rgb conversion to javascript and only had one minor issue. Sometimes the color values go out of the 0..1 range during the conversion. You have to clip them to 0..1 manually, the iOS color class does that automatically, but other than that it was pretty straight forward.

Do note that I did not convert the code that clips the xy values to be within the gamut supported by the lamps.

The sRGB wikipedia page http://en.wikipedia.org/wiki/SRGB seems to describe the conversion process with more math.

Dale Schultz

unread,
Apr 23, 2014, 12:59:53 PM4/23/14
to hue-h...@googlegroups.com
Thanks, that looks like the code I used, but I found that the reverse conversion would not produce the original value. I will look at it again and see if it is the same or if i made an error somewhere.

Can you round trip a value ?  i.e. RGB -> xy -> RGB  and get the 'same' result?

Dale
Reply all
Reply to author
Forward
0 new messages