An improved Basecurve Module

Hi all!

I am currently looking into improving the basecurve module.
The more modern tonemapping modules from the scene-referred workflow provide improved color management where the old base curve breaks - especially regarding hue shifts.
In addition, the current base curve module is a bit bloated IMHO - especially with the exposure fusion. Although it is a valid point to include such a functionality together with tone mapping, I believe that with the new modules like tone equalizer, it may be more appropriate to handle the dynamic range with those dedicated modules and let the base curve be a simple tool to define a transfer curve.

Why I still use the base curve?
Well!
The other modules define the tone mapping in a parametric way.
Here, the parameters often provide a more technical control - but less so direct artistic correspondence.
Good knowledge of the algorithm and color management is required to understand what is really happening when you change certain parameters and to predict what values will yield the desired image.
By the way, IMO the new agx module is a significant improvement here as parameterization is based on terminology that is quite common in vfx / film industry.
So, I noticed that especially when editing a lot of images for commercial work, fiddling with the parameters to get the look I want may can take more time than simply using the base curve, where I have direct control over the transfer curve.
So, sometimes, I prefer the base curve.

However, the old base curve module has it’s own caveats. In particular (in my opinion), the hue shifts without any color preservation are problematic - especially for skin tones and colorful highlights.
The available color preservation methods either yield problems with desaturation or control of lightness.
Sigmoid is liked by many users for the pleasing out-of-the-box look.
I assume this mostly results from the channel-independent mapping, which is also used by the base curve without color preservation. Especially with typical sigmoid-like curves, the channel-independent mapping may increase saturation for certain value ranges.
From a color-science perspective, this may be undesirable, as it breaks color consistency, but the results are visually pleasing and often have a “warm, film-like” appearance.
One may argue that this is valid in context of the processing pipeline because accurate manipulation should be done in the scene-referred stages, whereas manipulations in the display-referred space after tone mapping are perceptually driven either way.
Hue-Shifts are a problem, however (that’s why sigmoid etc. have optional hue correction)
And, most important in practical use for me:
Since a while, darktable allows values > 1 in the pipeline to support unconstrained scene-referred workflow without clipping between modules.
Filmic etc. handle this inherently by letting you define the black- and white point.
In the base curve, there is some extrapolation, but otherwise no controllable handling of the input range.
So, without exposure fusion, you need to compress the image range before the base curve, for example using a dedicated exposure module just before the base curve.

So, I have started working on an updated version and would like to know what you think about it!

Based on the findings above, I have employed the following design paradigms:

  • Prefer visually pleasing results over rigorous color science → take the best from sigmoid :wink:
  • Still, prevent hue shifts
  • Only do one thing: applying a base curve while controlling input range
  • Controls shall have direct artistic meaning

As WIP name I call the module “base curve rgb” to distinguish it from the old base curve.
The module has the follwing changes w.r.t. the old base curve:

  • Exposure fusion was removed
  • A slider to adjust exposure of the input was added → best to adjust exposure so that no cipping of any channel occurs so that input colors are not skewed.
  • A histogram of the expose-adjusted input was added to help exposure slider adjustment
  • Instead of multiple color preservation methods, there is one slider controlling the strength of hue preservation (like in sigmoid and agx). It preserves hue in OKHCL space as this yields better results than the method in sigmoid, especially for highlight IMO.
  • A slider to preserve highlight saturation allows to compensate for the desaturation of bright, saturated colors in the roll-off regime
  • The scale for graph slider was renamed and now has positive and negative range. This allows to also log-scale for the highlight region to facilitate more precise adjustment for highlights
  • Also, some bugs were fixed. Most importantly, curve drawing had low resolution on large log scaling values due to sampling in linear space. Now, curve is always drawn smoothly.

You can find the code here (with a lot of rough edges :wink: I’m mostly a python programmer and used my little bit of c knowledge + lots of help from AI to implement the module):

And the Appimage for Linux is here (import dialog does not work for some reason → I guess I have problems with my build environment…):
https://github.com/wilecoyote2015/darktable/releases/download/basecurvergb-0.1/Darktable-2.1.0+27203.g43252791a3-dirty-x86_64.AppImage

Please feel free to play around and share your thoughts!
There are still some issues to solve and I won’t be able to answer quickly as life keeps me quite busy, but I’ll give my best to improve the module over the time when I can :wink:

Here are some examples:
Vanilla Base Curve:


Preserve Hue:

Please note that I edited the image on an Adobe RGB display. Hence, the bright reds look a bit crushed in any version due to the mapping to sRGB gamut.

7 Likes

How does this module work for the different camera’s… I have often wondered wrt the base curve…there was a setting in preferences at one time to load camera specific basecurves (yes or no) and then there are the presets sort of 1 per camera manufacturer in the old module…

I guess the code just determined what type of file it was and applied the generic curve for say Sony or Canon etc…

Its just a question of curiousity really… and wondering if your module will just adopt this or interact differently …

1 Like

You should bring this up on github, if you haven’t already. You’ll have to provide a way back to the old base curve.

Have you tried the new AgX module that is currently under review?

Also @Pascal_Obry so he is aware.

1 Like

Yes, I’ve tried the agx module. I think it’s great!

Regarding darktable github: I wanted to get some initial feedback from users here first. If feedback should be negative, there’s no need to do all the code cleanups and bother devs with a pull request…

I have implemented it as a new module and not an update of the base curve module by intention because controls and algorithm are different and this way no backward compatibility must be considered.

2 Likes

This often fail short when tested over many different pictures.

Now, Base Curve was designed for Display Referred workflow, this legacy workflow is not something we want to develop anymore. We keep it to not break old edits.

Now for the Scene Referred workflow we have 3 tone mapper:

  • Filmic
  • Sigmoid
  • Agx (soon)

You’ll need to provide a proof that the new Base Curve fill a feature not yet covered by what we have today.

1 Like

In my hack software, I’ll sometimes use a control-point curve when I want specific control over each part of the curve. Your point about parametric curves resonates with me…

I for one would not want to see the fusion option removed. That is the only reason I ever use base curve.

Me too

Personally, I never use Base Curve anymore because it was designed specifically for the display-referred workflow.
In the scene-referred workflow, it’s hard to imagine we have a need for more than three. But if there’s something it can do that the others can’t, I’ll never complain about new functionality.

Although RGB Curves is not a tone mapper per se, I believe it works very much like Base Curve, and I do still use RGB Curves from time to time because I like the direct control of the curve that it provides. You can pinpoint an exact spot with the picker, and put multiple control points all along the curve. So I assume this is something you’re promoting as a unique feature that Base Curve could bring to the tone mapper.

I do enjoy this fine control, but not sure it’s necessary in the tone mapper? I usually use RGB Curves in conjunction with a tone mapper like Sigmoid.
One problem with RGB Curves is that it can quickly start to lose local contrast if pushed too far. Is Base Curve more robust in this regard?

Just as a note, while Base Curve has some limitations, there’s nothing inherently wrong with using it in a scene-referred workflow.

2 Likes

This confuses me. As @Donatzsky points out if you just use in i the display referred part of the pipeline there’s not even a theoretical issue or?

Sure you can use it in scene-referred workflow, but it is very hard as there is only a curve to squeeze all the data into the display. Better use a well designed module for this like Sigmoid. Note that Base Curve has never been a module used on it’s own. There is preset for Nikon, Canon… And properly generated curve for specific camera and this need a user to run a specific tool to get the curve. Again, to be Base Curve is to be seen as obsolete at this stage and we certainly don’t want a new module with the same design.

2 Likes