color calibration for any white balance (PR merged)

Dear All,

This morning my PR colorcalibration also for manual wb - #20304 has been merged. I’d like to thank everyone for their patience and support. User manual update will follow - your feedback would be important.

The PR was created to solve two issues: technical and usability.

Usability is probably more important, and that is what you are actually going to see immediately, so let’s start with that. As you know, in darktable the scene-referred mode splits the handling of white balance between two modules: white balance and color calibration. This is surely confusing for newcomers, but also veterans sometimes asked to have the “temperature” and “tint” controls, which are used almost universally, but so far have been unavailable with the scene-referred flow. For the scene-referred flow, white balance had to be in one of two modes: the older ‘camera reference’ (using initial ‘reference’ white balance coefficients generated from the camera matrix), or ‘as-shot to reference’ (using the camera’s as-shot multipliers up to input color profile, then switching to ‘reference’); the correct white balance would be achieved later, in color calibration, by using ‘as shot in camera’ or some other mode.

The most visible change is that color calibration’s new default illuminant setting is ‘from the white balance module’. When in this mode, it will follow whatever you set in white balance (the option should not be used with the ‘camera reference’ WB mode). At the same time, white balance gained a new checkbox, ‘prepare data for color calibration’. Having that ticked tells input color profile to perform the same kind of preparation that it did for ‘as shot to reference’, but is now available for any white balance setting (except for ‘camera reference’, where it would do nothing, ‘converting’ reference to reference, so is hidden). Most controls of white balance are only available if color calibration uses the from white balance module illuminant setting, in order to reduce confusion regarding where white balance parameters are actually set.

There’s a new warning to remind you to tick prepare data for color calibration if you forget:

It is still possible to combat a wrong camera profile (the ‘caveat’ mentioned in the user manual). Your saved presets (including any matrix fix preset) should continue to work. To create such a preset:

  1. turn off color calibration - this enables all white balance controls, and disables (and hides) the prepare data for color calibration checkbox
  2. pick your white balance from a shot of a D65 calibrated screen
  3. save the preset

You can then apply the preset to any photo; color calibration must not be in from white balance module mode, as now the RGB coefficients in white balance are used not to balance the image, but to replace the wrong ‘reference’ multipliers:

Now, the technical side: some modules, such as highlight reconstruction and denoise (profiled), work better if the the image is properly white balanced (in the sense that neutrals are correct). This was the reason as-shot to reference was introduced: the camera’s estimate of illuminant is better than a fixed D65 reference value. This change simply takes it one step further: you can now choose (pick from the image) what the correct illuminant is.

What I’d like to ask from you is to test: do you experience weird colour shifts compared to previous exports? Usability issues? Wrong warnings? Anything you find confusing and should be modified on the UI, or very carefully explained? Highlight reconstruction, denoising, raw chromatic aberration suppression not working as it should (as it used to)? Please provide sidecars for darktable 5.6.x and for the new version, so I can have a look - it would be impossible to fix an issue like ‘it does not look as it used to’.

Thanks in advance,
Kofa

19 Likes

@kofa …
thx so much for your effort and hard work .
I will try as soon as it appears in the nightly …
Looking forward to it … does sound promising

Regards Andreas

1 Like

Hi Kofa,

I’m not at all sure I understand what changed and how this effects my current way of approaching white balancing.

My approach: In the past I’ve created references for all my cameras and lens combinations. These are auto applied by the white balance module when triggered. I also auto apply ‘as shot in camera’ in the color calibration module. Worked like a charm for me.

In the new situation these presets are picked up and applied and I end up with a situation as shown in the last image of your OP. However…

If I do not auto apply the ‘as shot in camera’ color calibration setting and only apply my white balance preset I end up with ‘from the white balance module’, which is auto detected by the color calibration module I guess.

You mention this:

I’m really curious what the correct combo is, because using ‘as shot in camera’ gives me a white balance module I cannot do anything with and using ‘from the white balance module’ is incorrect if I interpret the quoted paragraph correctly.

I oftentimes manually adjust white balance in the field (auto white balance can mess things up quit a bit at times), so I want to end up with the white balance my camera recorded as a starting point. No “corrections” applied by darktable.

As a side note: Please show the numbers, be it greyed out, in the white balance module, even if the cannot be adjusted. Showing some sliders, in what seems to be the correct locations, and nothing else seems a bit pointless.

I’m not sure what you mean. Lens should have nothing to do with the white balance + color calibration flow. What kind of reference are you talking about? The matrix workaround described at color calibration - caveats ? Those should work as before.

It’s not auto detected: it’s the new default. The previous default was as shot in camera, which then immediately switched to daylight/black body/custom, depending on which was the best approximation of the actual camera values. If you want that, the flow is still usable, but you’ll have to add a new color calibration preset that sets as shot in camera.

Yes, because in that mode the illuminant (the parameters color calibration uses internally) are derived from what the camera gives you, so there’s nothing to adjust in white balance.

So, please provide more info.

In the past, the defaults were:

  • white balance in ‘as shot to reference’ → was the same as ‘as shot’ + ‘prepare data for color calibration’ is now
  • color calibration defaulted to ‘as shot in camera’, and automatically switched to an approximation

For these, the new default of:

  • white balance: ‘as shot’ + ‘prepare data for color calibration’
  • color calibration with ‘illuminant: from the white balance module’
    does exactly the same (subject to rounding errors, if any).

If you have one of those cameras that needs the matrix workaround, then you loaded your custom, measured coefficients into white balance, and never used white balance to neutralise the image, anyway. That can stay the same: ‘user modified’ mode in white balance without ‘prepare data for color calibration’; you fix your white balance in color calibration, as before, simply not using the from the white balance module option.

If it’s something else, please let me know.

Aurélien Pierre came up with this as a very good, but initially elaborate way to set a starting point in the white balance module. In very short: Photograph a white screen with camera+lens combo, white balance using picker in white balance module and make preset (repeat for all camera+lens combos). I can no longer find the article/video resource he made about this years ago…

I’m still not 100% sure if I should keep the auto applied ‘as shot in camera’, although I do think I should. Maybe you can confirm that with the extra info given about my auto applied white balance settings.

That method is only needed if your camera’s matrix is incorrect. As I explained, it works unchanged: you achieve correct white balance by using the right illuminant in color calibration, just like before. white balance remains with the multipliers you picked from that photo of the monitor. You don’t have to do anything, besides switching color calibration away from using an illuminant from the white balance module. You can do that using a preset.

Got it.

Thanks!

1 Like

I’m not sure I get all this, (but I have previously not really understood the difference between as shot, as shot to reference and camera reference and their relation to CC …)

Does this imply that in the third screen-shot in first row, where CC is set with custom, the red, green and blue sliders in the cut-off channel coefficients section in white balance are also grayed out?

Yes, they are disabled. In this mode, white balance affects data until reaching input color profile; at that point, whatever multipliers you added before switching away from illuminant: from the white balance module are reverted to the ‘reference’ (matrix-derived) multipliers, they ‘only’ affect demosaic etc. color calibration is then used to white balance the image.

I would recommend against using this mode:

  1. if you know what the right white balance is, set it as early as possible, so you also optimise demosaic, highlight recovery etc.
  2. if you have mixed lighting, you can still use two instances of color calibration with complementary masks: set white balance to the ‘main’ illuminant, and use one color calibration with illuminant: from the white balance module, then add another instance with custom illuminant:
1 Like

I understand “this mode” to refer to custom. Further I catch that the main message is that while we previously in SR workflow have been told to leave white balance alone and do white balancing in CC, we are now rather advised to use white balance as the primary tool for white balancing (with the benefits you mention). Is this correct?

I’ve been struggling with the error message of using two instances of white balance. I think I will always struggle. All I need is straight forward WB with temp and tint sliders.
Thank you though for your work on this. Much appreciated!

Thanks for your labor @kofa, good stuff
I’ll test it in the next editing session

Basically, yes: set the correct white balance as soon as possible. color calibration is not for ‘creative white balance’, use color balance rgb for that.

Thanks!

And thanks a lot for all your work and in general for all your patience to explain things and answer uneducated questions. Highly appreciated! :clap: :clap:

Note: you still can use color calibration for “creative white balance”; it will disable the WB sliders in white balance, but the RGB coefficients remain effective to control the “technical” WB (neutrals). Still, Aurélien argues strongly against this, to be able to maximise dynamic range. You are free to accept to ignore his advice.

Is this going to be in the nightly builds? I could try that if I figure out how to set the testing config (db and stuff)

Yes, it was merged today and will be in the nightlies from now on (unless reverted due to serious issues).

1 Like

So in short, instead of being ‘as shot to reference’, this new mode is essentially ‘custom to reference’, and should be default since it feeds better data for highlight reconstruction and others?

Haven’t used the new mode yet so my understanding is very basic, but if so, I wonder if a new drop down option would be less confusing/finicky than a drop down + check box option?

Also, do the custom values work in reverse? Eg, if I tweak the custom values in colour calibration, does that then change the values in white balance? Because I quite like the colour calibration user interface for setting white balance. I like it better than tint and temperature.

1 Like

There are 3 modes where ‘prepare data…’ makes sense:

Unless I misunderstand your question, the panel would have needed 7 tabs:

  • as shot
  • as shot to reference
  • from image area
  • from image area to reference
  • user modified
  • user modified to reference
  • camera reference

Plus, duplicate entries for all drop-down entries, except for ‘camera reference’ (where the camera-specific modes are constructed dynamically, based on what multipliers are available for each camera):

No, they do not (communicating the white balance between the two modules is crazy enough already without such a feature). You can still use the ‘as-shot + checkbox’ method, equivalent to the previous ‘as-shot to reference’, then pick the colour in color calibration, it won’t go away. For maximum accuracy, you can actually pick an area in white balance to neutralise greys, that works up to input color profile; then you can set the final white balance in color calibration, if you really want to.

Maybe a direct illuminant selector (select the cast + strength of correction, like color calibration does) could be added to white balance directly. But let’s wait for the dust to settle a bit.

@kofa, re. the 3 pairs above i.e. with and without “to reference” - obviously old edits have to work, but going forward, what is the justification for White Balance being able to use those three options without “to reference”? That is, what would be wrong if DT always enforced the “camera reference”-style processing from input profile?