On Wed, Sep 30, 2009 at 4:39 PM, <lcms-user-request@...:
> Message: 1
> Date: Wed, 30 Sep 2009 08:11:16 -0400
> From: Robert V Canning <Robert.V.Canning@...>
> Subject: [Lcms-user] XYZ to RGB Conversion
> To: lcms-user@...
> Content-Type: text/plain; charset="us-ascii"
> I want to be able to convert an XYZ value to RGB. I took the
> following steps:
> - created a XYZ profile used as input.
> - created a sRGB profile used as output
> - intent is set to perceptual
> - created a transform
> - loaded the XYZ values
> - did the transform
> The problem is no matter what the XYZ value I always get 255 for the RGB
> values. What am I doing wrong?
> Thanks for any help.
> void XYZtoRGB(double X, double Y, double Z, unsigned char &red, unsigned
> char &green, unsigned char &blue)
> cmsCIEXYZ XYZ;
> BYTE output;
> XYZ.X = X;
> XYZ.Y = Y;
> XYZ.Z = Z;
> cmsHTRANSFORM hXYZtoRGBTransform;
> cmsHPROFILE hXYZProfile;
> cmsHPROFILE hsRGBProfile;
> hXYZProfile = cmsCreateXYZProfile();
> hsRGBProfile = cmsCreate_sRGBProfile();
> // Rendering intent is perceptual
> hXYZtoRGBTransform = cmsCreateTransform(hXYZProfile, TYPE_XYZ_DBL,
> hsRGBProfile, TYPE_RGB_8,
> cmsDoTransform(hXYZtoRGBTransform, &XYZ, output, 1);
> red = output;
> green = output;
> blue = output;
There are some problems regarding basic color spaces algorithm conversion,
some things need to be
modified to get the "proper" color "manually". One of the things I'd also
warn you about is the usage of the
rendering intent. Is there a specific reason why you use perceptual? It is
mostly used for photographs but
it affects other colors also in the conversion. In the end the output color
is different than input even if it is
inside the gamut due to keeping the proportions.
These things "do" affect the final sometimes that dE94 is bigger than
allowed (over 6).
I'd warn you about the colors that are in green (more affected) and yellow
color spectrum because they show
the biggest sensitivity regarding this kind o conversion.
Regarding the difference between D50 and D65... It is not as much visible
from the 550nm (green) but it does
affect the blue color a lot and may provide different results.
Best wishes, Marijana