Hi everyone, about one year ago, Esben H-R Myosotis wrote in “Emulating Adobe's color engine” (https://sourceforge.net/p/lcms/mailman/message/33544095/):
> The Adobe color engine has the annoying quirk that it limits the slope of the > transfer function for pure gamma profiles. They spill the beans in "Annex C: > implementation notes (Informative)" in the specification of the Adobe1998 > color space. > > Since a disturbingly large fraction of the world consider Adobe products to > be the standard of color management, it would be useful to have an option > that emulates this behavior. I have encountered the same issue, but with Apple’s ColorSync CMM (which uses seemingly the same formula although with factor 16 instead of Adobe’s 32). In fact, though it is not part of the ICC spec, this mechanism, known as “Slope Limit”, seems to be fairly widespread (e.g. Kodak’s CMM uses it, too – again with factor 16 (see the ProPhoto specification, page 5, http://scarse.sourceforge.net/docs/kodak/ProPhoto.pdf)). And Adobe’s and Apple’s CMMs are certainly among the most widely used CMMs. So I certainly agree with Esben that an option emulating this behavior would be very useful in Little CMS. Basically, what slope limiting does is to calculate a linear transfer in parallel to the transfer function of matrix shaper profiles, and then use the maximum or minimum value (depending on the direction of the conversion) of both. So, assuming TRC(V) is the transfer function that converts the (R, G, B) component value V, and that F is the aforementioned factor (32 for Adobe, 16 for Apple and Kodak), slope limiting means: for the RGB to PCS direction: V = max ( TRC(V) , V / F ) for the PCS to RGB direction: V = min ( TRC(V) , V * F ) Replying to Esben, Marti Maria has suggested to use Little CMS’ plug-in API to implement this behavior. But at least I fail to see how this could possibly work in a generally usable way. Also, I feel that the fact that slope limiting is so widespread warrants an emulation option in Little CMS itself. Therefore, I decided to patch the Little CMS source code directly. I’ll discuss how to apply this patch at the end of this post. Obviously, implementing the above slope limiting formula itself is extremely simple; it’s just a few lines of code in the cmsEvalToneCurveFloat() function in cmsgamma.c. The more tricky part and by far the one that requires the most code changes is to propagate the information when and which slope limiting should be applied to this function. My implementation offers two new dwFlags for cmsCreateTransform() and cmsCreateTransformTHR(): cmsFLAGS_SLOPE_LIMIT_16 and cmsFLAGS_SLOPE_LIMIT_32 This means you can decide on a per-transform basis whether slope limiting should be applied or not, and which one. (Obviously, cmsFLAGS_SLOPE_LIMIT_16 emulates ColorSync and the Kodak CMM, cmsFLAGS_SLOPE_LIMIT_32 emulates Adobe’s CMM.) Apart from these two additional flags, my patch does not affect the public API of Little CMS 2.7 at all. But of course, this also means that you’ll have no access to this new feature apart from the cmsFLAGS_SLOPE_LIMIT_16 and cmsFLAGS_SLOPE_LIMIT_32 flags. A modified implementation could change the public API of Little CMS and allow for more detailed access to this feature. I have tested the implementation in comparison with ColorSync and can confirm that it emulates the behavior of ColorSync exactly. I do not have access to the Adobe CMM, so I cannot confirm that it emulates the Adobe CMM as precisely as it does with ColorSync. You can download the patch file from ftp://ftp.ritual.org/common/ColorManagement/LittleCMS.2.7.SlopeLimit.patch (Make sure to use the binary mode with ftp so as to leave the patch file untouched.) Move LittleCMS.2.7.SlopeLimit.patch into the lcms2-2.7 directory. Then, in Terminal, go into the lcms2-2.7 directory and enter: patch -p0 -i LittleCMS.2.7.SlopeLimit.patch That should do it. (@Marti: If you want me to, I can fork the current development version of Little CMS on GitHub and issue a pull request for the patch.) Bye Uli _________________________________________________________________________ Uli Zappe, Christian-Morgenstern-Straße 16, D-65201 Wiesbaden, Germany http://www.ritual.org Fon: +49-700-ULIZAPPE Fax: +49-700-ZAPPEFAX _________________________________________________________________________ ------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140 _______________________________________________ Lcms-user mailing list Lcms-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lcms-user