Re: [Lcms-user] RGB-to-XYZ-to-RGB weirdness
An ICC-based CMM for color management
Brought to you by:
mm2
From: Derek B. N. <de...@gl...> - 2017-10-20 22:33:59
|
Hi Noel, > Out of curiosity I ran your code (with a trivial correction so that > the second printf says XYZ instead of Lab). I got this output: > > RGB 6a 3c 31 -> Lab 4f43 9466 9086 -> RGB 6a 3c 31 > RGB 6a 3c 31 -> XYZ 0adc 0884 03a3 -> RGB 66 32 24 > RGB 6a 3c 31 -> XYZ 0adc 0884 03a3 -> Lab 4f5e 945e 9088 -> RGB 6a 3c 31 That matches my output exactly. > Interesting that the two different sets of intermediate Lab numbers > led to the same RGB outputs in the first and last cases. I think the differences in Lab numbers are (expected) integer accuracy issues. I'm not really surprised that the 8-bit RGB values end up the same. (I haven't tried, but I would guess that 16-bit RGB output would also show small differences.) > Marti will have to say whether the RGB->XYZ->RGB numbers are "close > enough". Certainly I've come to know color conversions are often > not exact. I'm not expecting them to be exact. What confuses me is that converting XYZ to Lab and then to RGB "fixes" the problem. That makes me think there's something funny going on. My understanding is that XYZ and Lab are both well-defined color spaces (assuming a fixed white point), so I would expect either one to produce the same (or very close) output when converting to sRGB. That is, I would expect sRGB->XYZ->sRGB and sRGB->Lab->sRGB to produce similar output. > Bigger picture-wise, I suspect there is no underlying problem in the > library since I've been using LCMS 2.8 RC (with my performance mods) > in product testing and my results are as good as the previous > version's results. > > Did you try the various options flags? > > Also, perhaps there is not enough resolution even in the 16 bit > numbers... Have you tried the example using floating point? Ok, that's interesting: switching to TYPE_XYZ_DBL avoids the problem (even if I keep TYPE_Lab_16 as is). That may be a workaround for my application. I'll need to check and see what sort of peformance hit I take (I'm doing some manipulation in the XYZ space). Thanks for your help! I'm still curious to see if someone can explain what's going on here. Why does converting the XYZ_16 values to Lab_16 before converting to RGB "fix" the problem? - Derek |