Shadows/highlights compression: comparison between RawTherapee and Photoflow

Shadows/highlight compression is one of the fundamental tools in image processing.
Used with moderation, it can rescue images for which the dynamic range is too big to be properly displayed. However, it is a tool in which the actual algorithm being used plays a crucial role one the quality of the result. Shadows and highlights have to be separately processed without creating visible and unpleasant halos. This is usually achieved through various forms of edge-aware blur operators.

Recently there has been quite some work done both in RawTherapee (mostly by @agriggio) and PhotoFlow, to improve the visual quality of shadows/highlights compression. Since the two programs use a quite different approach, I thought it would be interesting to compare side-by-side the results on the same image. This is not meant as a “battle” between the two programs, but instead as a way to discern the pros and cons of the two approaches, and see if we can get the best out of the two.

The algorithm used in PhotoFlow is based on this work by Paris and Durand, and can be summarised as follows:

  • the input RGB image (assumed to be in linear encoding) is converted to log-luminance
  • the log-luminance is blurred with a bilateral blur operator
  • the high-frequency component is extracted as the difference between the original and blurred log-luminance values
  • a linear scaling is applied to the blurred log-luminance
  • the high-frequency part is added back to the blurred and scaled log-luminance
  • finally, the new log-luminance channel is converted back to linear encoding, and blended into the initial RGB channel

The algorithm typically produces a flat and dull result, but with preserved local contrast. A nice and easy way to re-introduce some global contrast, which IMHO generates visually pleasing results, is to apply a filmic tone-mapping curve to the result.

To illustrate all this I have taken the RAW image from the Volcan Stone Sunset PlayRAW, and generated a scene-referred 32-bit floating point TIFF (in linear Rec.2020 colorspace) that will serve as a starting point for both the PhotoFlow and RawTherapee edits.

Here is how the initial image looks like (the blown highlights are not really lost, they are just represented by values > 1):

I lifted the exposure by 1 EV and applied the dynamic range compression module with default parameters:

Finally I added a filmic tone mapping adjustment:

Let’s see how this compares with the new shadows/highlights module in RT. I still had no time to investigate in detail the RT algorithm, maybe @agriggio can provide some details…
One clear difference is in the blur method: RT uses a guided blur, while PhF uses a bilateral filter. I am planning to implement the guided filter in PhF as well, with quite high priority…

Here is the result of RT’s shadows/highlights applied to the test TIFF image:

Here are the two final results side-by-side (left: photoflow, right: rawtherapee). It is fair to mention that the RT version does not have any additional contrast adjustment applied to the shadows/highlights output:

Few ideas for discussion:

  • what is the best encoding (linear, perceptual, log…) for the blur step?
  • what about the adjustment of the luminance vs. the individual RGB channels?
  • what is the best approach to adjust the global contrast?
7 Likes

The left one from last screenshot looks better to me!

Edit: though I prefer the bright regions of the right one because they look more natural…

There is some :wavy_dash: near the sun on the right image.

That’s the PhF result…

The flatness of the bright highlights on the left is a consequence of the compression applied by the filmic tone-mapping. It can be easily “cured” with a simple RGB curve that rises the highlights:

Interesting topic. Re. your ideas for discussion @Carmelo_DrRaw , these are a bit above my knowledge level.
However I’d suggest trying your new process with aggressive settings using the “tester” tif I uploaded in the RT test shadows highlights topic a few weeks ago. There was some banding then, a few comments, but it was left hanging really.
https://discuss.pixls.us/t/test-the-new-and-enhanced-shadows-highlights-tool/9329

Also I’m interested in the difference between a dedicated shadows/highlights tool versus using a tone curve plus local contrast tool. I tried this this in RT using the film-like curve -


Vulcan-stone-2.jpg.out.pp3 (10.8 KB)

It’s not that far off the PhF one except for around the sun, which seems to be sitting in a bowl, is that what you were referring to @afre with the wiggle symbol? Anyone know how this pattern arises? And 10/10 @Carmelo_DrRaw for avoiding it! I still haven’t found time to get into PhF…

Yes, the more you push things a certain way, the more the seams in the gradients show. You just need to know which buttons to push. :stuck_out_tongue:

Hi,

That’s a nice result! I agree that it looks better than what you got with the shadows/highlights tool of RT. However, FWIW that’s not how I would use the S/H tool. (In my mind at least) the S/H tool is meant to be used for “fine tuning” the picture, to be applied with a “light touch”. RT has another tool, which happens to be called “Dynamic Range Compression”, which is what I would use to perform the bulk of the work. Here’s an example.

Your starting point:

2EV exposure lifting and Dynamic Range Compression with default parameters:

Then a simple S-curve:

And finally, a touch of highlights:

You can then add some local contrast later for a more “aggressive” look (though I won’t do that here).

2 Likes

Just to throw another contender into the ring, here’s Filmulator (without proper highlight handling yet, hence the patches of purple where the green channel is clipped).

Filmulator gives more color in the clouds and avoids the “bowl” around the sun.

2 Likes