Friday January 27 2012
An Online Community for Digital Photographers

Advertise on The Light's Right

L*a*b for Color Correction: The Pitfalls

Dan Margulis wrote a book several years ago, "Photoshop LAB Color: The Canyon Conundrum and Other Adventures in the Most Powerful Colorspace," that advocates L*a*b conversion for many basic photographic adjustments.

There are times when a L*a*b conversion offers important advantages. Anytime you need to isolate color and tonal information, a L*a*b conversion is the way to work. The need to more completely isolate color and tonal information than RGB or CMYK can accomodate, however, is not all that common for the digital photographer who is making basic adjustments to color or tone.

There are some serious considerations with the L*a*b conversion maneuver that you should consider:

  • The photo goes through the Adobe Color Engine (ACE) twice. There are few output devices that use L*a*b. So, you end up converting to L*a*b and then back to RGB or CMYK.
  • The L*a*b colorspace has many nonexistent colors. In fact, approximately 2/3 of the L*a*b triplets (64.9%) result in colors that are imaginary and cannot be reproduced on any output medium.
  • Approximately one-half (49.5%) of the colors in L*a*b are outside the AdobeRGB gamut. Similar percentages for sRGB and ColorMatchRGB are 65% and 64.8%.

The practical implications are obvious.

First, whacking around color and tone in L*a*b means the likelihood that some pixels take on unreproducible colors. When you convert your photograph back from L*a*b to another colorspace, something has to be done with those colors that are "out of gamut" back in something like AdobeRGB or sRGB or even ProPhotoRGB (where 12.7% of the L*a*b colors are beyond its gamut).

Second, the fact that so much of the L*a*b colorspace is "wasted" means that it "squeezes" the reproducible colors together in a much smaller space than the entire. This invites severe quantization errors when moving back to a smaller colorspace, like AdobeRGB or sRGB. This can result in visible artifacts, like posterization.

There is a third practical implication that is not so obvious. 

Because of quantization errors, you will almost certainly lose important color information with the conversion from something like sRGB or AdobeRGB to L*a*b. Why? The answer is quantization errors. That's geek-speak for a simple concept. Color is not discrete, it's continuous. Photoshop represents color components as integers, and math with integers means rounding issues. For example, do we consider 128.5 to be 128 or 129?

Bruce Lindbloom did a simple experiment. He made a 4096x4096 sRGB TIFF with each pixel representing a unique, real color. Then he converted it to L*a*b (using the Relative Colorimetric rendering intent). The result? Unique colors dropped from 16,777,216 to 2,186,578. That's a drop of 86.97% in unique colors.

http://www.brucelindbloom.com/

What happens is that multiple sRGB values convert into a single L*a*b value as a result of quantization errors. A 16-bit TIFF with 12-bit or 14-bit depth would experience fewer quantization errors, but it would still be a significant number.

Am I arguing against L*a*b conversion. No. But, I would urge caution. And, I would avoid automatic conversion to L*a*b for routine adjustments to color and tone. There are situations where a L*a*b conversion has it's advantages. Removing difficult color casts is one example, as Dan Margulis demonstrates in his book.

decoboy's picture

Math theory doesn't translate to the 'real world' very well

Hi Mitch, as usual for me a lengthy reply

From the start I must state I'm a bit of a Dan Margulis fan - he can get carried away a bit - but his contribution to 'real world' image manipulation - in particular photographic, is right at the top of the tree. So...

I agree with your last paragraph -
"Am I arguing against L*a*b conversion. No. But, I would urge caution.."

However I differ on much of the rest. This is a worthy topic as many, many people are 'afraid' of Lab as if it were the big bad wolf. So.....your comments and my responses:

"There are times when a L*a*b conversion offers important advantages."
Agreed - and I add there are times when you should never use it - Dan's book is a must read on this topic. In particular Lab can be a bit of a sledge hammer

"Anytime you need to isolate color and tonal information, a L*a*b conversion is the way to work."

Yes, but I don't like the term 'tonal' -luminosity or brightness or even colour and detail is closer to the mark. I'm not being picky here - this is one of the biggest hurdles to the understanding of Lab - it separates (like HSB) colour and Lightness. Why is this important? Because you can make colour changes WITHOUT affecting the detail in the image - this is not the case in RGB or CMYK - where ANY 'basic' (see below) colour change by definition and by visible result modifies (and usually damages) the detail in the image.

"The need to more completely isolate color and tonal information than RGB or CMYK can accommodate, however, is not all that common for the digital photographer who is making basic adjustments to color or tone."

Disagree on both points
a) IMO it is very difficult to effectively 'isolate' colour and lightness (tonal) in RGB or CMYK - the 'brightness' sliders in Hue/saturation, Exposure etc. in PS are 'clumsy' tools and IMO are much more damaging than any trip to Lab. An alternative method (i.e. not basic) is to create in RGB a 'Lightness' layer by using a B&W conversion, change the colour layer to suit and apply the Lightness layer in Luminosity mode
b) On the contrary, basic (as opposed to minor or trivial) adjustments often involve large changes to colours - this is where Lab excels - BTW in Lab you effectively have Blue/Yellow and Green/Magenta channels as opposed to just Red Green & Blue channels.

"...the fact that so much of the L*a*b colorspace is "wasted.......invites severe quantization errors when moving back to a smaller colorspace,"

No it ain't - it is usefull for 'impossible colour' techniques. And I suggest you read pages pages 119 to 134 of Dan's Canyon book and try it a similar 'torture test' yourself.

Now,....Bruce Lindbloom's test.
Hmmmm.... Mitch maybe you should have mentioned that he and Dan have some "history" on a couple of points since 2003 or earlier - readers should visit this at Bruce's site:

http://www.brucelindbloom.com/DanMargulis.html

Bruce's 'test' IMO is irrelevant - because the subject he used was irrelevant, this was an image of what exactly? :). This type of test is just a (mathematical) stunt. - amusing but pointless.

Also he somehow forgot some of his own numbers - on the test you mentioned he blames the reduction on the Lab conversion to quote:

"All of the loss may be attributed to quantization, that is, multiple unique RGB colors collapsing into a single Lab color. "

Oh really? Gee I guess he forgot to read his own site where at :
http://www.brucelindbloom.com/ReferenceImages.html

he states that because of the way Photoshop "represents 16-bit image data" then, now get this...
"simply opening and saving one of the 16-bit reference images will reduce the number of unique levels per channel by about half (which will also reduce the total number of unique colors)."

oops big time! So why blame the it all on the Lab conversion? UPDATE - I got this wrong - see my post on 10/12 below Oh also, I can't find anywhere on his site what tool he used to calculate the # of unique colors in any of the images. I tried a few tools (and got some weird results), the closest was PaintShop Pro X - see below

Update - Bruce uses PSP as well

So I figured I'd do my own simple test following his guidelines (AFAIK).

My test used one of Bruce's (computer generated) test files from here:
http://www.brucelindbloom.com/ReferenceImages.html
I used the DeltaE_16bit_gamma1.0.tif , a 36 meg uncompressed file, this sort of a 'real' image, even though it was computer generated. I understand he does this to avoid 'noise' - once again in the 'real world' we always have noise - thus it has little to do with real situations.

Bruce states this has 1,045,769 unique colors. Using PaintShopPro I got a value of 1,007,918 which I guess is close enough.

My tests all used the original file as follows:

1- opening and re-saving to test the 'loss' caused by PS
2- opening convert to Lab to RGB and re-save - no other changes
3- opening and making a basic change in Hue/Saturation in RGB
4- as per 3 except change to Lab for the Hue/Sat change

here are the results from the count unique colours in PSP-

Orig was 1,007,918
1 = 838,233
2 = 761,046
3 = 807,380
4 = 747,323

I also performed the H/S changes in RGB on the #1 file, interestingly this came out with the EXACT same # as #3 which used the original file. Unless I'm mistaken this suggests that any 'losses' in 2, 3 or 4 need to be taken from # 1 value, as this is what I suspect Photoshop works with.

Hmmm, what happened to the supposed massive loss of of all those colours? What was it 86.97%? The RGB mods 'lost' about 3.7%, the Lab mods about 10.8%, anyway, if a particular Lab result looks better - isn't that more important than some pesky numbers?

I think the readers need a proper explanation of why a 'disaster' rarely occurs.

So what is my take on this? Well after using Lab in my workflow for some years now, I see it like this:

1 Most people fear Lab because they don't 'get it' and spend their life in one colour space

2 Lab is quite simply a sledge hammer, not to be used (for the most part) for delicate modifications or for the faint hearted

3 The often quoted theoretical mathematical 'damage' rarely relates to 'real world' situations. Many are seduced by the 'sky is falling' scenario that these equations suggest.

4 I never see the theorists mention what is the capability of the typical human eye in regards to seeing the difference between colour x and y - what is the smallest difference they could see. As far as I can discover it is NO WHERE NEAR 16 million steps - yes the human eye can see a wider range than the best colour space - but can we discern a difference of step 13,101,199 and 13,101,200?
5 Can the best screen display the difference of the smallest step - and if it could could we see it anyway?

6 Exceptions, there are always some, delicate gradients for example can benefit, and certain computer generated images (ah ha this is what was tested)

Brian - Melbourne Australia

decoboy's picture

Forgot to mention what the mods were!

In the mods test I simply used Hue and Saturation at -10 and +5 respectively. IMO this is a little unfair to Lab, as this is not what you would typically use it for.

However it enabled me to duplicate the same adjustment - one that should directly affect colour.

Lab is usually/should be used for particular purposes, mostly those that cannot be achieved as well (or not at all) in RGB or CMYK.

Brian - Melbourne Australia

decoboy's picture

BTW here's another simple test

One of Lab's big advantage is in blurring, especially when one wants to soften colour transitions, but not lose detail.

So I tried a simple test - apply a 5 pixel Gaussian blur to the same test file above-

In Lab apply the blur just to the a and b channels

In RGB the only way you can do this is to the 'Edit-Fade blur 100% colour mode' (which only affects the colours) or you can use an 'original layer' above the blur in luminosity mode - both ways have the same end result.

Guess what - the Lab result has clearly better colour transition, and GOSH more unique colours. The RGB does okay but has some clumsy colour transitions - and less unique colours.

And this is with a computer generated image - full of computer gradients - something that Lab should have ruined.

Oh My, back to the calculator :D

Brian - Melbourne Australia

decoboy's picture

Correction - apology to Bruce - and some new issues!

Mea culpa,

I emailed Bruce about my ? re PS losing most of the colours due to it's 16bit approach. Bruce rightly pointed out that the test file for the 16 million colours was only 8 bit. He also advises he uses PSP to count the colours as well.

My apologies to Bruce for suggesting that he did not read his own website.

However - this raises some important questions - see below in the reply I sent to Bruce - (Mitch I hope you don't mind):

.......

Bruce, Thanks for the prompt reply, I had forgotten the RGB16million file was 8 bit.

Reproducing the test as you describe I achieved the same #'s as you did.

Re paint Shop Pro, glad we are using the same tool - I found some rather bizarre results using other tools such as Irfanview and some free downloads specifically designed to count colours. Only PSP got it right.

I'm finding some rather interesting outcomes from other tests:

1. in the RGB16million test, one can avoid any losses by converting to 16bit mode, before going to Lab and back, thus if this worried anyone it is easily fixed.

2. if dither is used under colour settings, (I find this is recommended by most image processing gurus) then the Lab and back to RGB count increases to 5,129,437

3. Converting the image to AdobeRBG reduces colour count to 7,754,574 or 8,670,372 depending on whether you use dither - interestingly the greater loss is incurred using dither - exactly the opposite to that in the Lab conversion - I'm guessing because at such high numbers of colours (over 8 million) the dither 'collapses' the difference between some pixel values - whereas with only Lab's 2.18 million the dither 'generates' additional colours.

4. I was somewhat surprised that the Lab conversions produced little if any banding (with or without dither). I also found that one needed to enlarge to 200% or more (on my pro monitors) before any visual difference was noticeable.

Re the 16bit files - do you agree that Lab conversion does little or no 'inherent' damage make sense to you? Of course if one was deliberately inducing 'impossible' colours then the results would differ - but of course this is/should be done to produce a desired effect.

Finally if one converts from RGB to CMYK and back - the result is 4,257,568 - double that of the Lab file, of course the image is nothing like the original, with obvious banding. Which begs the question - do all those extra colours really matter?......

And this is the crux - IMO counting colours has little if anything to do with a good result - anyway - in the vast majority of images (not graphics) how many of those colours were noise, how many of them were 'real'?

Brian - Melbourne Australia

mitch's picture

Theory v. Empirical Results

Brian:

Thanks you for your comments. This is the sort of dialogue I like to see on this site. I'd like to see more. :)

I agree that theory has it's place, but it is practical, real world experience that matters.

I'm not surprised that the results with 16-bits are different than wth 8-bits. That actually goes against a major claim of Dan Margulis over the years -- that you can edit most photos in 8-bits without visible degradation.

The fact that going to L*a*b with 12-bit or 14-bit depth does not settle the issue for me. That really doesn;t tell us anything that we can expect if we do significant editing in L*a*b.

I agree, blurring is often better done in L*a*b. It does depend on how extreme the blur being applied. The TLR Digital Velvia actions actually make a duplicate, go to L*a*b, do their saturation boost there, and then copy the result back. I did that, precisely because some of the actions make a substantial saturation boost, and L*a*b is advantageous for that.

My issue with Dan's book, which you also seem to sense, is that it is too partisan. He does caveat the L*a*b maneuver can damage a photo but the overall gist of the book is that converting to L*a*b is a risk-freeoperation that can benefit any photo.

I agree that the techniques he shares can be beneficial. He certainly made me more aware of the possibilities of L*a*b editing. But I have always felt that it is a technique that requires care and that it is often done more as a flourish to demonstrate technical proficiency than really required to better edit a photograph.

It would be hard to market a book that demonstrates lots of technique, only to tell the reader than for 99% of the photos you'll likely edit, the L*a*b maneuver is unnecessary.

For example, I see many people urging L*a*b converison for sharpening. Use a Luminosity blend or Fade To Luminosity and there is almost zero benefit. Even if you boost the magnification to something like 400%, you cannot see an appreciable difference between L*a*b sharpening and RGB sharpening with a Luminoity blend. At print size, I've yet to see prints that could pass a blind test. Even with a loupe and an exgremely sharp and critical eye. No owner of a print would be disappointed with the RGB result. Do I sharpen in L*a*b. Yes, if I'm in L*a*b for another reason. I wind up there less than 1% of the time.

decoboy's picture

Mostly agree - plus a test that damages the Theory!

Hi Mitch,
Re the 16 bit benefit - I'm afraid I'm about 80% on Dan's side here, i.e. that for the vast majority of photos 16 bit has minimal advantage and one can simply convert when needed.

Computer generated images - especially ones full of software gradients - are obvious exceptions (as Dan notes). BTW the test files referred to in this blog are all computer generated - zero 'noise' files - and thus have zero relevance to ANY digital photo.

Mitch, I agree with your comment on sharpening in Lab, no great benefit and the difference is (mostly) barely visible to a 100% luminosity fade in RGB. The exceptions is where you have strong colour changes in detail areas. RGB sharpening introduces clumsy halos compared to Lab L only sharpening.

However.... this comes back to the point I raised in point 4 of my first post namely:

Is this 'loss of colours' of any importance - or is it just mathematical scaremongering ?
Can we see it? - in my experience I have never found anyone who could (without zooming to 200% or more).

BTW some of my professional photo image work involves high end jewellery and diamond work - possibly the most technically difficult photography I've experienced. These images are highly processed, from dozens of focus step stacks, and complex curves and blends to get the most out of the stones. They are closely scrutinised by my clients as they are often used in glossy mags.

After a number of 16/8 bit comparison tests I (and my clients) can see no benefit in using 16 bit files (which take much longer to process). Why - because they can't see a useful difference - on the contrary - the 8 bit images appear (to my clients) to be 'sharper' and print better. As you know this is not a surprising phenomenon.

NOW FOR A SIMPLE TEST - which should cripple the myth of Lab 'damage' (remembering that these test images are probably ones that should bring out the 'worst' in a Lab trip)

Mitch please try this - and share your thoughts on the outcome:

1 - Take the DeltaE_16bit_gamma1.0.tif file - convert in PS to 8 bit and save tagged as sRGB.

2- Re-open this file, apply a simple curve to all channels - say +/- 10 to both ends - then save it

3- Do the same except do it in Lab- return to RGB and save (this is trickier as you'll need to do each channel separately.

Now use PSP to count the colours - I got:

1 = 150,758 (from the 1,045,769 in 16bit) - yikes a loss of 85.6%!!

no matter

2 = 137,756 (done in RGB)some slight banding visible

3 = 153,614 (done in Lab)- banding visually same as RGB

Oh dear - Lab gave us more colours so it MUST be better yes? Well, no - this was probably due to the small dither applied by PS, and with only 150k colours to start with it IMO is bound to add some.

The big ? is - where is all this monumental damage that going to Lab was supposed to cause - huh? I've tried this with H/S changes etc and the outcome is the same.

Here are the big dirty secrets that the number junkies don't want to talk about:

a) Very few 16 bit photographs have more than 10 million 'unique' colours in them - out of the billions possible
c) Very few 8 bit photos have more than 1-2 million colours - out of a possible 16 million
b) ALL digital photos/scans have a fair bit of noise - which makes up a good chunk of these so called 'unique' but technically false colours
c) So called 'quantization' losses are small at these lower %'s of maximum colours- almost none in 16-bit
d) Editing can often increase the colours count - the lower the original colour count - the more likely it will happen
e) These rarely visible 'losses' are almost always outweighed by the improvement to the image - assuming it needed it.
f) Changing into Lab and back -WITHOUT DOING ANYTHING- is a CON. Ask yourself - why do these tests not involve doing anything that a typical 'better in' Lab move would require. Answer - because the results would make the number junkie look foolish.

I look forward to replies - especially from those that take the trouble to do their own tests and investigations.

Regards

Brian - Melbourne Australia

Using LAB

I purchased Dan's LAB book and found it very useful. Even Dan admits that going to LAB is not really necessary in many cases.
What I've found with actual photos is:
For most photos if you're pressed for time the simple LAB moves at the start of the book usually give a pleasing print (not the best you can expect) with little time required (as Dan claims).
For critical work (looking for the best print possible or at least that I'm capable of), some of the LAB moves and blends really really help.
Using the LAB a and b curves needs care or you'll end up with highly exaggerated colors, but they give the ability to bring out colors that is hard to do in RGB space.
After I've played with Dan's moves for several months, I've learned that many of my photos don't seem to really benefit from LAB moves and so don't use them.
Scott Kelby recommends some LAB moves in his 7-Point System for Adobe Photoshop book to add additional pop. Basically go to LAB and use apply image to apply either a or b channel with overlay, or one of the light (soft light for example) blends. Use opacity to help control. Dan suggest somewhat more complicated but similar moves. Again Scott's move is useful for some, but not all, photos.
I do agree that there is theoretical damage to moving to LAB, but I've never seen damage in real photos to going to LAB, editing there, returning to RGB for additional editing and then printing from RGB. (All edits produce some loss of data so the idea is to make sure the cost of lost data buys you improved photos.)
I think people should add LAB to their toolbox, but realize that there is no need to go there for every image.
I also find it useful to use the LAB data in the info pallet to help color balance images even if I'm working in RGB.
One thing I've noted that on some forums you can generated lots of heat and no light by mentioning any of Margulis' ideas.

Les

http://www.ncsparks.com