How to get XY value from ct.
Ex: ct = 217, I want to get x="0.3127569", y= "0.32908".
I'm able to convert XY value into ct value using this below code.
float R1 = [hue[0] floatValue];
float S1 = [hue[1] floatValue];
float result = ((R1-0.332)/(S1-0.1858));
NSString *ctString = [NSString stringWithFormat:@"%f", ((-449*result*result*result)+(3525*result*result)-(6823.3*result)+(5520.33))];
float micro2 = (float) (1 / [ctString floatValue] * 1000000);
NSString *ctValue = [NSString stringWithFormat:@"%f", micro2];
ctValue = [NSString stringWithFormat:@"%d", [ctValue intValue]];
if ([ctValue integerValue] < 153) {
ctValue = [NSString stringWithFormat:@"%d", 153];
}
Now I want reverse value, which is from ct to XY.
On Phillips HUE
2000K maps to 500 and 6500K maps to 153
given in
ctas color temperature but can be thought as actually beingMired.Mired means
micro reciprocal degreewikipedia.ctis possibly used because it is not 100% Mired. Quite sure Phillips uses a lookup table as a lot CIE algorithms do because there are just 347 indexes in this range from 153 to 500.The following is not a solution, it's just simple concept of a lookup table. And as the CIE 1931 xy to CCT Formula by McCamy suggests found here it is possible to use a lookup table to find x and y as well. A table can be found here but i am not sure if that is the right lookup table.
reminder so the following is not a solution, but to find an reverse algo the code may help.
at least this is proof that x and y will not sit on a simple vector.
CCTmeanscorrelated colour temperatureand like the implementation in the question shows can be calculated vian= (x-0.3320)/(0.1858-y); CCT = 437*n^3 + 3601*n^2 + 6861*n + 5517. (after McCamy)but a
cct=217is out of range of above link'ed lookup table.following the idea in this git-repo from colour-science and ported to C it could look like..
this seems to work fine with CCT between 2000 and 25000, but maybe confusing is CCT is given in Kelvin here.