Hi,

I've a generic questions regarding CMS and hope that somebody can help me.

My task is to convert RGB values to Lab and calculate DeltaE (CIE94) from a
reference value.
The RGB values are in sRGB and so I do the following.
I'm not really sure how to use cmsAdaptToIlluminant and I don't know if the
way I calculate Lab is correct.
Thank you very much for your help.

Stefan Schadt



cmsHPROFILE hInProfile; // This is sRGB as ICC profile
cmsHPROFILE hXYZProfile; // XYZ built-in profile
cmsHPROFILE hLabProfile; // Lab built-in
cmsHTRANSFORM hTransformRGB2XYZ;
cmsHTRANSFORM hTransformXYZ2Lab;
cmsCIELab Lab; // Calculated Lab

// Open ICC profile
hInProfile  = cmsOpenProfileFromFile("sRGB.icc", "r");

// sRGB values come from a digital camera and are recorded at 5600 calvin.
cmsCIExyY WhitePointT;
cmsCIEXYZ WhiteCamera;
cmsWhitePointFromTemp(5600, &WhitePointT);
cmsxyY2XYZ(&WhiteCamera, &WhitePointT);

// Whitepoint of ICC profile is D50 as per definition
cmsCIEXYZ WhiteICC;
cmsCIExyY WhiteICCT;
cmsWhitePointFromTemp(5000, &WhiteICCT);
cmsxyY2XYZ(&WhiteICC, &WhiteICCT);

// Create built-in profiles and transformations
hXYZProfile = cmsCreateXYZProfile();
hLabProfile = cmsCreateLabProfile(NULL);
hTransformRGB2XYZ = cmsCreateTransform(hInProfile, TYPE_RGB_8, hXYZProfile,
TYPE_XYZ_16, INTENT_PERCEPTUAL, 0);
hTransformXYZ2Lab = cmsCreateTransform(hXYZProfile, TYPE_XYZ_16,
hLabProfile, TYPE_Lab_DBL, INTENT_PERCEPTUAL, 0);

// This is my input
BYTE RGB[3] = {200, 200, 200}; // example

// And I calculate Lab as follows:
cmsCIEXYZ XYZ, XYZt;
cmsDoTransform(hTransformRGB2XYZ, RGB, (LPVOID)&XYZ, 1);
// This is to adapt 5600 to 5000 calvin of ICC profile
cmsAdaptToIlluminant(&XYZt, &WhiteCamera, &WhiteICC, &XYZ);
cmsDoTransform(hTransformXYZ2Lab, (LPVOID)&XYZ, (LPVOID)&Lab, 1);

// So I have my calculated Lab in 'Lab'.
// My reference Lab:
cmsCIELab LabReference;
LabReference.L = something;
LabReference.a = something;
LabReference.b = something;

// And DeltaE:
double DeltaE = cmsCIE94DeltaE(&Lab, &LabReference);


That's all.
Is this the correct way to calculate DeltaE ?




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Lcms-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to