Experiments with local contrast enhancement

During the past days I have been experimenting with local contrast enhancement, in view of improving the shadows/highlights tool in PhF.

The first step was to integrate the guided filter from RT, for edge-preserving blur.

Then I started to play with it to see how it can be used to enhance the local contrast.
The procedure is rather simple: extract the high-frequency local contrast by properly combining the original and blurred copies, and then superimpose the local contrast to the original version.

The usual way to do that is to subtract the blurred image from the original one, and then add back the result to the original. This is AFAIKk what GIMP grain extract and grain merge blend modes do.

However, I noticed that subtract/add approach affects the shadows in a rather “harsh” way, especially when working with linear RGB data.

here is the initial image for my tests:

and here is the result of the subtract/add approach:

However, this is not the only possible approach. If the subtraction is replaced by a division, and the addition by a multiplication, if have the impression that re output is more “natural”, with smoother shadows and a better enhancement of small-size highlights:

This might be useful for other tools as well…

What do you think?

4 Likes

To me, subtract looks more natural.

Have fun!
Claes in Lund, Sweden

I prefer the substract/add approach when working with gamma 2.2 (LAB trc is even better probably).

When working with linear data the division/multiplication approach looks super good :muscle:

Here are the results when working in Lab encoding:

subtract/add:

divide/multiply:

In this case, I agree that the add/subtract version looks a bit better. In the other one, the bright parts seem to be over-enhanced…

Personally, I have been jumping between -,+ and /,*. Neither are satisfactory but I still use them when they work because the guided filter is fast.

This work is in the perspective of re-injecting some lost local contrast after shadows/highlights adjustments, or to slightly increase the local contrast like shown above, but at a much lower strength…

I’d be interested to see a larger blur radius, looks a bit too “enhanced” perhaps with a small radius?

Local contrast enhance has its uses of course. I used to use it a lot more than I do now because the result tends to look nice up close. But from ten feet away, when the eye sees a larger swath of the surround, often results of local contrast enhance alogirthms aren’t so nice. Or as my husband pronounced once when I proudly showed him my nicely “improved” image: “Looks spotty”.

For the particular test image in this thread, I’d use a very small Curves adjustment to slightly separate relative brights and darks in the trees, with the “stationary” point of the curves set at the peak of the histogram.

I have a filter that does it in two steps: first a small radius, then a larger one. The shadow problem doesn’t go away though, just less apparent and more spread out.

It makes the shadows more uneven per patch and also lifts certain shadows.

Yes, I would do something like that. I haven’t really experimented with curves and thresholds yet.