Hi!

I've had a long discussion with Elle Stone who did a huge comparison of the 
results image applications have when converting between 16 bits linear rgb and 
srgb. It turned out that Krita gave different results from tifficc, so I dug in 
a bit and found that the reason was that I didn't use the cmsFLAGS_NOOPTIMIZE 
flag when creating transforms, while tifficc does. Code like this:


    quint16 src[4];
    src[0] = 257;
    src[1] = 257;
    src[2] = 257;
    src[3] = 65535;

    quint16 dst[4];

    cmsHPROFILE sRgbProfile = cmsCreate_sRGBProfile();
    QByteArray rawData = linearRgb->profile()->rawData(); // from krita... it's 
a linear scRGB profile, as attached.
    cmsHPROFILE linearRgbProfile = 
cmsOpenProfileFromMem((void*)rawData.constData(), rawData.size());

    cmsHTRANSFORM tf = cmsCreateTransform(linearRgbProfile,
                                          TYPE_BGRA_16,
                                          sRgbProfile,
                                          TYPE_BGRA_16,
                                          INTENT_RELATIVE_COLORIMETRIC,
                                          cmsFLAGS_NOOPTIMIZE | 
cmsFLAGS_BLACKPOINTCOMPENSATION);

    cmsDoTransform(tf, (quint8*)&src, (quint8*)&dst, 1);

    qDebug() << dst[0] << dst[1] << dst[2];


returns 3266,3266,3266, while 


    cmsHTRANSFORM tf = cmsCreateTransform(linearRgbProfile,
                                          TYPE_BGRA_16,
                                          sRgbProfile,
                                          TYPE_BGRA_16,
                                          INTENT_RELATIVE_COLORIMETRIC,
                                          cmsFLAGS_BLACKPOINTCOMPENSATION);

returns 1595,1595,1595

Which surprises me, since I would have thought optimization wouldn't have any 
influence on the actual results obtained. Is this a bug, or should I always use 
cmsFLAGS_NOOPTIMIZE to get accurate results?

-- 
Boudewijn Rempt
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl

Attachment: scRGB.icm
Description: application/vnd.iccprofile

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to