I want to display correct colors on a mobile device Android/iPhone so I created an ICC profile for each device. My colors are in L*a*b* (CIELAB) format. The conversion from L*a*b* to RGB goes through the XYZ color space and I use math from Bruce Lindbloom's web.

Problem is, that the algorithm to convert XYZ to RGB (all over the web, not only on Lindbloom's web) converts directly to the sRGB profile. Then I convert from sRGB to my device's ICC profile (I use the 'SampleICC' library from www.color.org). Is there a way to convert the XYZ values directly the my device's profile and skip the sRGB, preferably using the SampleICC library, or is there any other C/C++ library for applying ICC profiles? ...with documentation and/or examples. I want this for better precision.

EDIT: Based on @Nikita Nemkin advise I tried the little CMS where I used the built-in Lab profile and created a transformation like this:

cmsHPROFILE outProfile = cmsOpenProfileFromFile("my_profile.icm", "r");
// Lab to RGB with custom ICC profile
g_LcmsTransform = cmsCreateTransform(cmsCreateLab4Profile(cmsD50_xyY()), TYPE_Lab_DBL, outProfile, TYPE_RGB_DBL, INTENT_RELATIVE_COLORIMETRIC, 0);

This gives me a bit different results, then my previous algorithm (Lab -> XYZ -> sRGB -> RGB with custom ICC profile) using the SampleICC library, especially for darker colors. This is partialy because I do not adapt darker colors in Lab -> XYZ conversion in my first algorithm. The really bad thing is that both of these conversion gives different results then conversion in Photoshop. For example:

Lab (18, -30, 70) is sRGB (0, 54, 0)
SampleICC RGB (39, 57, 24)
SampleICC RGB with proper dark colors handling (45, 57, 24)
LittleCMS RGB (39, 54, 0)
Photoshop RGB (45, 55, 0)

all conversion are done with relative colorimetric intent and in Photoshop I used black point compensation and the Adobe engine. Which number should I trust? Is there any 100% reliable software to check my values?

有帮助吗?

解决方案

Little CMS is a popular open-source (MIT license) color management library. It should be able to do what you want.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top