Dear all
I'm new to the list.
I have wrote some color temp transform function.
And realized lcms able to do the same, I'm just trying clear my
misunderstanding and make sure my implementation is correct.
( even though it look very close to photoshop raw plugin already )
What I do is this
1) first I get colortemp from and to and make a xy ( assume no lower
then 2000k )
if( colortemp >= 2000 && colortemp <= 7000 ){
xyy->x =-4.607 * pow(10, 9)/ pow(colortemp, 3) +
2.967800 * pow(10,6) / pow(colortemp, 2) +
99.11 / colortemp + 0.244063;
} else {
xyy->x = -2.0064 * pow(10,9)/ pow(colortemp, 3) +
1.9018 * pow(10,6) / pow(colortemp, 2) +
247.48 / colortemp + 0.237040;
}
xyy->y = -3 * pow( xyy->x, 2 ) + 2.87 * xyy->x - 0.275;
2) Then XY to XYZ by assuming y = 1
new_xyz->X = orig_xyy->x / orig_xyy->y;
new_xyz->Y = 1;
new_xyz->Z = (1-orig_xyy->x - orig_xyy->y)/ orig_xyy->y;
3) Then using BradFord matrix to get the white reference rgb
R = new_xyz->X * BradFord[0][0] +
new_xyz->Y * BradFord[1][0] +
new_xyz->Z * BradFord[2][0];
G = new_xyz->X * BradFord[0][1] +
new_xyz->Y * BradFord[1][1] +
new_xyz->Z * BradFord[2][1];
B = new_xyz->X * BradFord[0][2] +
new_xyz->Y * BradFord[1][2] +
new_xyz->Z * BradFord[2][2];
4) New we get Source Color RGB white reference and Dest Color RGB White
Reference for making the transformation matrix
matrix[0][0] = BradFord[0][0]*destRGB->R/srcRGB->R;
matrix[0][1] = BradFord[0][1]*destRGB->G/srcRGB->G;
matrix[0][2] = BradFord[0][2]*destRGB->B/srcRGB->B;
matrix[1][0] = BradFord[1][0]*destRGB->R/srcRGB->R;
matrix[1][1] = BradFord[1][1]*destRGB->G/srcRGB->G;
matrix[1][2] = BradFord[1][2]*destRGB->B/srcRGB->B;
matrix[2][0] = BradFord[2][0]*destRGB->R/srcRGB->R;
matrix[2][1] = BradFord[2][1]*destRGB->G/srcRGB->G;
matrix[2][2] = BradFord[2][2]*destRGB->B/srcRGB->B;
5) transformation matrix = matrix * Reverse_BradFord
Now we can start working on RGB
6) RGB->sRGB (by gamma apply)
if( RGB <= 0.04045 )
RGB / 12.92
else
pow ( ( (0.055 + RGB)/ 1.055), 2.4 ) ;
7) sRGB->XYZ (by multiple D65 transform matrix)
X = R * D65[0][0] + G * D65[1][0] + B * D65[2][0];
Y = R * D65[0][1] + G * D65[1][1] + B * D65[2][1];
Z = R * D65[0][2] + G * D65[1][2] + B * D65[2][2];
Here is the question.. I see you are using D50 transform matrix
which is for printing color space? I'm not sure how to choose, any idea?
8) XYZ * transformation matrix
9) XYZ back to sRGB
10) sRGB back to RGB
So basically is
RGB->sRGB->XYZ->Transform->XYZ->sRGB->RGB
I'm not sure what I'm talking about ... could someone tell me I'm right
or wrong :)
Thanks
Alex
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Lcms-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lcms-user