darktable article lede image
Mastering color with Lab tone curves

Mastering color with Lab tone curves

or “How to bring the jungle back”

Since its early beginnings darktable has a tone curve module that is able to alter the gray level distribution of an image. Recently we did an enhancement: tone curve is now able to control the full Lab color space with separate curves for the L, a and b channel. People who are used to curve tools in RGB, at first might get puzzled over the results of these three curves; they show marked differences to the typical RGB curve. Especially a and b channels need to be dealt with in the right way; not doing so will give you strong off-colors. To spare you frustration here are some explanations and examples.

First a few words about Lab color space in general. Colors in this system are described by three parameters. Channel L stands for the lightness of the color and goes from 0 (black) to 100 (white). Channel a goes from -128 (green) to +128 (red) and channel b from -128 (blue) to +128 (yellow). All neutral gray colors have a = 0 and b = 0. For more explanations visit https://en.wikipedia.org/wiki/CIE_Lab. It might sound surprising, but with these three values L, a and b you can describe all visible colors, and even invisible ones. In fact colors as recorded by a digital camera will by far not use the full range of possible a and b values. If we would generate a histogram of a typical color image, channels a and b would only cover a narrow range (maybe ±30) around the center.

Now, how can we make use of curves in Lab color space? Adjusting channel L is like adjusting the gray value (a sum of R, G and B) in RGB. Giving the L channel an S-like curve will enhance overall contrast of the image. In the steeper parts of the curve, tonal values get more separated. In the flat part of the curve, tonal values get more compressed. An S-like curve will therefore typically bring together the very dark and very light values, respectively, and extend the middle gray values. In the end this will allow for better differentiation in the middle grays, and that’s what we as humans see as a more contrasty, detailed image. In darktable’s standard settings of module “tone curve”, a checkbox is activated that reads “autoscale Lab chroma values according to L”. In this mode you are only offered to modify the L channel. Chroma values – i.e. a and b channels – will receive some automatic scaling to keep the overall impression of color saturation constant, but you can not actively modify them. If you only plan to do some optimization of tonal values, you don’t need to go further.

However, if you want to optimize colors, deactivate the aforementioned checkbox and you are presented with additional curves for the a and b channels. These two channels do not describe lightness but contain pure color information. Changing them with curves can alter the overall tint of the image or change saturation and color contrast. It can bring similar colors further apart or different colors closer together.

Let’s have a closer look at an example. [side remark: when you look at this and the following images and ask yourself “what the hell is he talking about”, chances are high you are viewing them with an uncalibrated monitor. In that case all colors can be way off, especially in terms of saturation. For any serious color work or even to follow these examples you will need to get your monitor profiled.]

tc2-bild0.sm_

This photo was taken at a small canyon in the lush green forests of the island of Madeira. I was heavily impressed by the abundant vegetation; and that’s what I wanted to show. The person on the bridge was meant to act as a size reference and bring some color counterpoint to the image. However with the standard settings (I only added highlight reconstruction and a slight change of exposure value) the red is so strong and the green is so weak, that all focus lies on the person wearing a red anorak, certainly not what I intended. We could now simply increase overall saturation using module “color correction”. However, this would even further exaggerate the reds.

Using module tone curve my focus lies on the slope of the a-channel (green-red): I made it steep on the left side and flat on the right. As a result this increases saturation of the greens and keeps the reds under control. You might wonder about the outer wings of the curve, which have a slope just about the opposite of what just said. Well, these outer wings really don’t play a role. As said previously, in reality only moderate values of a and b will occur in a photographic image.

tc2-bild1-Lab

Here is the result of my changes:

tc2-bild1.sm_

OK, the green is now more visible and the red is better under control. Still the image lacks something convincing to turn the green into a real jungle. In fact all “greens” are more or less the same here. That’s not the case for green foliage in reality. Leaves show all kinds of variations, from a more yellowish green to a more blueish green. If that’s the case, why not enhance the blue-yellow differentiation? We can do this by giving the b channel a very steep S-like curve:

tc2-bild2-b

Here is the final result. Quite convincing and close to what I felt, when I made the shot.

tc2-bild2.sm_

In the previous exercise I payed extra attention to not move the a and b curve out of the center of the diagram. Any move of that center node would give a color tint to the whole image. Not a good idea if the white balance of my picture is already good.

Now comes a second example. This time I will deliberately change the color tint. The photo was taken on a very cold evening in Düsseldorf, Germany. We had several days of frost, and it was just possible to risk first steps on the virgin ice surface to take the picture. Module “equalizer” gave some clarity to the image.

tc2-bild3.sm_

Admittedly the result is probably a quite realistic representation of the light situation at that day, but it’s not what I wanted to express. I was experiencing an intensely colored sky, reflecting on an untouched ice surface. And it was really cold (at least for Düsseldorf conditions). For me coldness translates into more blueish colors, and yes, these should be visible in the image.

I applied the following curves.

tc2-bild4-Lab

Both a and b curves show a steep profile to increase color saturation. In addition I shifted the center node of the b-curve only a little bit down, moving the overall color tint to blue.

tc2-bild4.sm_

Stark colors, not overly realistic, but that’s what I experienced that evening.

For further reading on using Lab color space to optimize your images, I strongly recommend Dan Margulis textbook “Photoshop LAB color: The Canyon Conundrum” (Peachpit Press 2006). It puts a heavy focus on Photoshop, but the basic principles also apply to darktable.

Filed under: Blog Development Color Darktable Lab Saturation Tone Curves Tutorial
These are comments from the old website, archived as static HTML
  1. Thanks for the article. Very illustrative indeed. Maybe it is time to start thinking on LAB more than RBG? I'll give it a try.
  2. Beautiful! I can't wait to play with this when it hits Pascal's "unstable" PPA. Thanks for your great work!
  3. Bob Giles on Mon Feb 13 09:11:07 2012:
    Great post! Roll on version 1
  4. Thanks for this article. I learned a lot and have had a fiddle separating some shades in a/b as well - what surprised me wasn't just the separation but I managed (stunningly easily but perhaps more by accident than judgement) to get a much more pleasing and natural enhancement on some blue reflecting water than I could manage with colour zones.

    I love the separation on your 'jungle' foliage and feel abit inspired to rework a couple of my Bali shots where it is also mostly about the greens. Looking at your jungle shot I see the downside to the green separations on the foliage is the slate blue tone the watercouse has taken on - anyone for masks????

    Also, I can see how the a/b curves give you the control on reg/green and yellow/blue axis, but what is the approach if you wanted to separate red/yellow or blue/green I wonder?
  5. For the latter part: stay tuned. There will be an option soon (but probably not before 1.0).
  6. Thanks a lot! Great post.