On Wed, Sep 30, 2009 at 4:39 PM, <lcms-user-requ...@lists.sourceforge.net>wrote:
>
> Message: 1
> Date: Wed, 30 Sep 2009 08:11:16 -0400
> From: Robert V Canning <robert.v.cann...@usa.dupont.com>
> Subject: [Lcms-user] XYZ to RGB Conversion
> To: lcms-user@lists.sourceforge.net
> Message-ID:
> <
> of30eaff67.2634439c-on85257641.003f38ce-85257641.0042f...@cdcln05.lvs.dupont.com
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> 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[3];
>
> 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,
> 0,
> cmsFLAGS_NOTPRECALC);
>
> cmsDoTransform(hXYZtoRGBTransform, &XYZ, output, 1);
>
> red = output[0];
> green = output[1];
> blue = output[2];
> cmsDeleteTransform(hXYZtoRGBTransform);
> cmsCloseProfile(hXYZProfile);
> cmsCloseProfile(hsRGBProfile);
> }
>
>
Greetings!
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
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user