Re:The SRGB Learning Curve
by madaxe_again on Wednesday December 02, 2015 @08:18AM
(#10662740)
Yeah, it's usually the latter - and when we do know it's Adobe RGB we do exactly what you recommend, going via CIELAB - but it's not precise, and clipping does occur.
We're leaning towards "please upload a valid image" as a solution, which is a shame, but the whole perceptual end of things makes doing this automatically nigh on impossible - can't come up with a solution that works for all cases.
If you know the image is Adobe RGB (e.g. it has an embedded color profile, or has an "Adobe RGB" metadata tag) then you should either keep that metadata around, or if you want to turn it into an sRGB image you’ll need to convert the colors of every pixel. Since the Adobe RGB gamut is larger than the sRGB gamut, for some images you’ll need to map out-of-gamut colors into the sRGB gamut, either by hard clipping them (I recommend clipping along constant hue/lightness lines in CIELAB or CIECAM02 space) or by doing a more sophisticated transformation. There are lots of possible choices to make when gamut mapping. If you’re interested in the details there was a ~1000 page book published on the subject a few years ago. :-) (Or the easy thing is to just let some existing color management software like Apple ColorSync, LittleCMS, or whatever Adobe’s thing is called handle the gamut mapping for you, though in my opinion they all do a relatively mediocre job, unfortunately.)
If you don’t know the image was Adobe RGB – i.e. the metadata was stripped out before it got to you – then there’s not a lot you can do, unless you want to examine the color content of the image and come up with some kind of heuristic for guessing the color space.