Page 1 of 1

Lab Implementation

Posted: 2010-05-15T23:09:55-07:00
by stupid
Hi all.

I've just been attempting to sharpen images using the L channel of Lab. This should be straightforward but the overall brightness/gamma is substantially altered. An example:

Running -colorspace Lab -channel R -unsharp "0x0.8" +channel on

Image

produces...

Image

I've tried this same method using HSB, HSL, YUV, brightness and lightness channels and everything works normally. Is this an oddity in your implementation of Lab, something to do with the USM, or contention between the two?

Thanks.



Jo

Re: Lab Implementation

Posted: 2010-05-15T23:26:00-07:00
by fmw42
I am not an expert on this, so take with a grain of salt. see http://en.wikipedia.org/wiki/Lab_color_space

LAB may not be totally reversible when transforming to RGB (as LAB has a larger gamut than RGB), and L may not be linear. One or both may be the cause of your results, which I verified on IM 6.6.1-9 Q16 Mac OSX Tiger.

Re: Lab Implementation

Posted: 2010-05-16T00:08:37-07:00
by fmw42
I tried a simple round trip RGB to LAB to RGB and got the same color change.

convert img2641d.jpg -colorspace LAB -separate -set colorspace LAB -combine -colorspace RGB img2641d_test3.jpg

convert img2641d.jpg -strip -colorspace LAB -separate -set colorspace LAB -combine -colorspace RGB img2641d_test4.jpg

convert img2641d.jpg -colorspace LAB -set colorspace LAB -colorspace RGB img2641d_test5.jpg

convert img2641d.jpg -colorspace LAB miff:- | convert - -set colorspace LAB -colorspace RGB img2641d_test6.jpg

All of these produced the same color change you noticed.

I don't know if this a problem with LAB colorspace large gamut or a bug with IM.

Re: Lab Implementation

Posted: 2010-05-16T00:17:56-07:00
by stupid
Hey, fmw42. Thanks for the response.

Yup, I understand the difference between Lab and RGB; but the result of flipping modes should be barely perceptible - if at all - to the human eye. Photoshop manages translations Lab/RGB - RGB/Lab well enough so I expected ImageMagick to be similar - swapping to Lab is a fairly standard trick to avoid shifting hues (and noise) when sharpening. Looks like I'm back to two-layer sharpening then!


Thanks again!



Jo

Re: Lab Implementation

Posted: 2010-05-16T00:21:33-07:00
by fmw42
I understand what you are saying and I would expect a round trip to be reversible.

Post a message in the Bugs forum at viewforum.php?f=3 pointing back to this topic in the User's forum and it will likely get looked at by the IM folks as a potential bug.

As you are offline, I have gone ahead and posted to the bugs forum

Re: Lab Implementation

Posted: 2010-05-16T00:27:12-07:00
by stupid
Yes. Not a bad idea.



Jo