New local contrast tool

This might be due to the underlying algorithm, which tends to favour and “over-enhance” bright details in dark areas.
The exact formula that is used is
L' = L \times (L / S)^{(\gamma * A)}
where L is the input luminance, S is the smoothed luminance, A is the “amount” of the local contrast adjustment, and \gamma is a correction factor that is used to further control the strength of the effect.

When S coincides with mid-gray, \gamma is set to 1. When S is darker than mid-gray and L > S, \gamma is set to a value > 1, or in other words the effect is “boosted”. If L < S then \gamma is set to a value < 1, so that the effect is limited. This avoids that dark details are pushed too far on the dark side.
A similar but opposite logic is applied to areas where the blurred images S is brighter than mid-gray.

For performance reasons, all calculations are done in log encoding, so that multiplications are replaced by sums, and powers are replaced by products.

You can find the actual code here. Do not hesitate to ask about the details, or propose improvements!

There is no gamut mapping in the local contrast module. Is this coming from an additional layer?

1 Like