Preserve local contrast in the highlights after tone mapping

Is there a way to achieve pre-tonemapping levels of local contrast in highlights present in the RAW file after applying a tone mapper?

Here’s what I mean.

Look at the amount of detail and colour in the sky with the tone mappers disabled. All the modules are set to default.

This is the proper exposure of the midtones, which naturally blows out the sky, since there’s no tone mappers enabled.

When I enable “sigmoid” with its default settings, it maps the range to where it needs to be, but as you can see, the sky has lost all of its detail and colour.

If I push the contrast down and reduce the exposure slightly, I can see a little bit of detail appearing in the sky, but nowhere near the no-tonemapped version. And I being to compromise on my exposure a bit.

This is the setting that somewhat naturally represents the sky that I want to achieve, but it involves heavy underexposure.


Now “filmic rgb” does a better job at the cost of a slight underexposure - it’s set to 2.8 in here. Yet still, the detail is nowhere near the non-tonemapped image.


Here I’m back to the original exposure (3.1), now using “tone equalizer” without a tone mapper. The result looks very promising, but due to the nature of the applied effect (it’s done with clever masking and so on), I need to introduce this shoulder all the way from upper-midtones to achieve a natural looking effect. This compromises on midtone contrast.

Now if I turn on the default “sigmoid” in addition to this, it butches the sky once again. Colour is gone, texture is partially gone.

The skew pushed to the right, which, as per description in this tooltip, is supposed to favour contrast in the highlights, doesn’t do much beside lifting the highlights a little bit.

A fine tuned “filmic rgb” does a good job here, but still not quite there.

If we inspect this bit closer, you can clearly see how in the “raw” file (on the right) there’s a clear gradient going like this: a darker warm cloud, a slightly brigther warm cloud, a patch of bright blue sky, followed by a darker blue cloud, then a brighter warm cloud, and finally a darker warm cloud. Meanwhile, it looks much more simplified in the tonemapped image.

And finally, the same configuration with “filmic rgb” (left) versus a better exposed (1.0) configuration with the “base curve” preset “ricoh-like” (right). The result looks quite similar if we discard the fact that the rest of the image is heavily underexposed.


So how can I achieve a proper local contrast and colour in the highlights while also having a tonemapped histogram and a proper dynamic range in the image?

1 Like

I recommend that you share that raw file with a proper release so folks can show you via xmp files.

1 Like

Here’s the raw file.

R0011392.DNG (30.6 MB)

Release?

1 Like

Pardon, it’s darktable 5.2.1 on Windows 11

Please don’t forget to explicitly state the license you want to release your image with! A common license used here includes something like below:

This file is licensed Creative Commons, By-Attribution, Share-Alike.

1 Like

This file is licensed Creative Commons, By-Attribution, Share-Alike.

3 Likes

My edit with dt 5.2.1


R0011392.DNG.xmp (9.5 KB)

1 Like

My final edit for this.

But it’s truly painful to achieve, and very easy to miss unless you pay attention to the data you have in your RAW file. I have tone mappers disabled by default due to this.
I wish the process was easier and I didn’t have to choose between tone mappers at all - because I generally prefer the colour rendition (and control over it) with “sigmoid”, but only “filmic rgb” can bring out the true tonality of the RAW file.

R0011392.DNG.xmp (152.0 KB)

3 Likes

There’s always a compromise: your input dynamic range (‘contrast’, as measured by the ratio of the brightest and darkest areas; limited by what you camera can capture – it may even be a merged HDR stack with an even wider DR) is much higher than the output (limited by the screen).

tone equalizer can be used to compress that range while preserving local contrast (it uses an exposure mask to achieve this, essentially adjusting exposure by region, not by individual pixels), but any such treatment can lead to halos (due to the blurred mask crossing sharp boundaries).

One trick I use is local contrast masked for the highlights. Import these via preferences → presets, apply them and play with the mask.

highlight details.dtpreset (1.1 KB)
highlight details (subtle).dtpreset (1.1 KB)

5 Likes

The result is worth the trouble though!

Exactly that. Good to switch the tonemapper off and on while having a good look at your RAW. When making difficult pictures (with a lot of contrast) darktable will not do it automagically right for you. The nice thing is that practice brings more speed and ease to your workflow.

I’m not sure you’ll have to choose between tonemappers for each and every difficult photo. In this case Tone Equalizer, multiple instances in order to locally enhance the contrast and tonality together with some masking may be your friend.

There are some pretty good video’s about this out there, f.i. this one - I dare say - is a must for you: https://www.youtube.com/watch?v=VQGoCyns7_g

3 Likes

I like darktable and I use it every day, but sometimes it’s just frustrating that I need to fiddle with it for 30 minutes to achieve a neutral result (never mind a stylized one), whereas with the proprietary software this entire workflow consists of importing the image and bringing up the exposure, takes 10 seconds plus the lag that such software tend to come packed with.

I hope the new tone mapping module coming in 5.3 would improve this situation.

Nope, it won’t. It’s still a per-pixel curve. Lightroom et al probably use some local contrast tricks as well.

4 Likes

Sure enough it can be frustrating from time to time. I come from LR and I do not recognize the ease of use you assign to ‘proprietary software’. I remember struggling a lot with imperfect masks. I feel much freer now although I regularly struggle with masking or figuring out how to do certain things. And my results are surely better with dt. Of course your mileage may vary.

But please do watch the video as it addresses exactly your struggle with the Xmass tree / sky picture. There is a part in it where the tone equalizer is used to bring down a sky preserving contrast and then bringing it partly up again enhancing further the contrast.

Kind regards Jetze

3 Likes

I’ve taken note of that video but it’s too long for me to watch it now, so I’ll give it a go later. Thanks for bringing it up though. I have seen a lot of Boris’s videos, but sometimes I forget that I could go looking at his channel for a solution too.

1 Like

This is with exposure picked from the lower part of the image, tone equalizer lifting the shadows, AgX pivot set from the clouds to maximise contrast there (I’m not sure it’s worth it, the subject is the tree, not the sky), and local contrast (a global default instance, and one for highlights):

R0011392.DNG.xmp (10.2 KB)

A different mood, concentrating on the tree:


R0011392_01.DNG.xmp (11.2 KB)

5 Likes

Yeah, nice ‘playing around’!

I guess the OP prevers a dimmer evening light like version. But this shows beautifully what is possible.

@dfcsd end this year you’ll have dt 5.4 and will be able to play around with AgX module too. You’ll have even more choises to make then :innocent:

3 Likes

Having taken a look at this, I’m left with a confusion.

AgX, filmic, sigmoid, all, like most dt modules, allow masking. But… Are we not supposed to use one instance of one tonemapper? Does it make any sense for that instance not to apply to the entire image?

You may mask one instance and use exactly complementary mask for the next instance. Or divide your picture with three parametric masks and use three instances…

1 Like

I used two instances of tone equalizer to preserve the exposure of the sky and lift the dark foreground.

However, I also used AgX found in DT5.3 which will be available in DT5.4 later this year. You will find AgX more flexible than Sigmoid or filmic for handling the problems you have with this image.




R0011392.DNG.xmp (11.8 KB)

16 Likes