From: Lukas S. <som...@gm...> - 2020-08-16 08:12:05
|
Hello. In the last months, I've started to develop a colour picker widget based on the LCh model: https://github.com/sommerluk/perceptualcolor It displays a given colour space gamut (sRGB or something other) within LCh diagrams, to provide a perceptually uniform colour picker with a nice UI. It's under MIT licence. However, I'm new to colour management and don't have much experience with it. It would be great if I could get some help here. 1.) ========== What is the best way to know the gamut of a given colour space? What I try to get is this: https://raw.githubusercontent.com/sommerluk/perceptualcolor/master/other/expected.png The colour blob in the middle is a cut through the LCh model at a given lightness (the gamut is the sRGB gamut here, but it should work also with other gamuts). The code works like this: – Create a buffer with a Lab image – Transform it with LittleCMS like this: cmsHPROFILE labProfileHandle = cmsCreateLab4Profile(NULL); cmsHPROFILE rgbProfileHandle = cmsCreate_sRGBProfile(); m_transformLabToRgbHandle = cmsCreateTransform( labProfileHandle, // input profile handle TYPE_Lab_DBL, // input buffer format rgbProfileHandle, // output profile handle TYPE_RGB_DBL, // output buffer format INTENT_ABSOLUTE_COLORIMETRIC, // rendering intent 0 // flags ); – Test for each pixel if one of R, G or B component is outside the range 0–1. If so, treat is as transparent. If not, paint it actually on the screen. This approach works. However, there are also problems. a) If I understand correctly the paper “Unbounded Color Engines” than LittleCMS might switch to bounded mode if the profile does not support unbounded mode. So comparing the output channels to the range 0–1 would be useless, and the approach might not be reliably. b) It is slow, and does not provide proofing. So I tried something different: cmsHTRANSFORM xform = cmsCreateProofingTransform( labProfileHandle, // Input profile handle TYPE_Lab_FLT, // InputFormat rgbProfileHandle, // Output TYPE_BGRA_8, // OutputFormat rgbProfileHandle, // Proofing INTENT_ABSOLUTE_COLORIMETRIC, // Intent INTENT_ABSOLUTE_COLORIMETRIC, // ProofingIntent (cmsFLAGS_SOFTPROOFING|cmsFLAGS_GAMUTCHECK) // dwFlags ); It relies directly on LittleCMS for the out-of-gamut detection. It seems that out-of-gamut colours are automatically transparent. The problem is that the out-of-gamut detection seems to be far less exact than the other method. Therefore, the gamut image has a very strange shape: https://raw.githubusercontent.com/sommerluk/perceptualcolor/master/other/actual.png What would be the recommended approach here? 2.) ========== I've used INTENT_ABSOLUTE_COLORIMETRIC as rendering intent. It this the correct choice for this use case? 3.) ========== The build-in Lab profile has D50, but the build-in sRGB has D65. Does this matter? Or can I safely ignore that? Best regards Lukas Sommer |