Strange presets behavior of Darktable white balance module

It’s quite a bit more complicated than that.

Modules that come after white balance need to know whether the user wants to use white balance + color calibration (proper chromatic adaptation) or white balance only (bringing neutral to R=G=B, but not rendering colours how the eye would actually see them).

There are 3 options (I haven’t worked on this during the holidays, so I may not remember all the details correctly; please forgive me if that is the case):

  • the ‘legacy’ white balance modes: these perform the R=G=B correction (for greys) only. The benefit is that highlight recovery, demosaic (maybe also profiled noise reduction also benefits from this, I don’t remember) have neutral greys / whites to work with, which improves their quality. In input color profile, the colours (not properly adapted to D65) are adapted to D50 (darktable’s internal profiles use D50, and so does the ICC standard). Since the original ‘neutral correction’ is not a proper chromatic adaptation, colours remain slightly skewed.
  • the original scene-referred ‘camera reference’ mode: in white balance, multipliers derived from the camera matrix, belonging to the matrix’s white point (usually D65), are used. In input color profile, colours are adapted to D50 (white balance is still wrong, it does not match the scene). Finally, in color calibration, the as-shot multipliers are extracted from the EXIF / you may set or pick a grey point, and proper chromatic adaptation is done based on the scene illuminant (calculated from the EXIF / your values). This, unlike the simple ‘R=G=B for neutral’ done in white balance (‘legacy’), shifts all colours properly. The drawback is that demosaic, highlight reconstruction etc. don’t have the right neutral point (they process an image that’s white balanced to D65 or whatever the camera matrix uses, so greys/whites are not quite neutral).
  • the ‘as shot to reference’ mode tries to combine the best of both worlds, trusting the white balance from the camera to be closer to the correct values than D65. It sets a flag to indicate ‘the image does not have the D65 multipliers applied, but later we want to use color calibration’. Then, demosaic etc. can have (close to) neutral greys; input color profile sees the flag, undoes the camera multipliers and applies D65; chromatic adaptation is done properly in color calibration.

What I’d like to do (what I have been working on) is to be able to set this flag ‘the image does not have the D65 multipliers applied, but later we want to use color calibration’ manually on the ‘legacy’ tabs of white balance (it’s not as easy as it seems). Then, you could set your white balance multipliers in white balance to produce R=G=B (or use the ones from the camera if they are good enough), effectively following the ‘as shot to reference’ path, but using any set of multipliers. Then, in color calibration, we could have an ‘as set in white balance’ option (in addition to ‘as shot in camera’) to do the adaptation. ‘as shot in camera’ would still need to remain, because we still have to support the use case when the multipliers in white balance are used to correct a broken camera matrix, as described in the caveats section of color calibration.

5 Likes

Thanks for your thoughts. I think I get the gist of it, though I have no idea if/how the D50 aspect affects things.
I have tried to summarise the requirements that seem to be needed. Hopefully this helps understanding and discussion, certainly my understanding. Is the following about right?

  1. White Balance module
    For new edits it needs to provide RGB coefficients for the following -
  • user wants to use the camera-assigned white balance
  • user wants to set the balance from a part of the image
  • user wants to adjust the balance by eye
  • user wants to use one of the currently supported manufacturer presets e.g. cloudy
  • user wants to enter specific coefficients, for example to correct for a bad camera matrix

(There is no need for the Camera Reference option any more)

For old edits, previous processing needs to work of course.

  1. Demosaic, Highlight Reconstruction etc.
    New edits are to use the coefficients provided by the White Balance module
    Old edits to work as before

  2. Color Calibration
    This is more complicated. The manual says
    “By default, color calibration performs chromatic adaptation by:
    • reading the RAW file’s Exif data to fetch the scene white balance set by the camera,
    • adjusting this setting using the camera reference white balance from the white balance module,
    • further adjusting this setting with the input color profile in use (standard matrix only).”
    So are the requirements like this? -

  • user is to continue to be able to use chromatic adaption which is based on camera white balance
  • user can also choose adaption based on the White Balance module’s coefficients
  • old edits to work as before

BUT
if the user thought the camera balance was good, surely they would have used it in White Balance, and conversely, if they haven’t used it then it should be considered potentially unreliable, so, why not always use White Balance coefficients as the basis for the adaption?

  1. Other modules that currently benefit from “Camera Reference”
  • these modules are to continue using D65

Another requirement
I think White Balance going forward should record the user’s “intention” as well as the coefficients ensuing. E.g. “cloudy”, if they selected an area from the image, if they used camera balance. I don’t think it stores all or any of this at present.

That’s quite an essay. :slight_smile: thank you, I’ll read it during the weekend.

Since quick thoughts:

There is the special case when the coefficients in white balance are used not to set neutral greys, but to fix the camera matrix (‘caveats’ section in the manual). For those, reading the EXIF multipliers is still the best default.

Nothing really ‘benefits’ from D65: it’s a technical requirement:

  • the camera matrix, used in input color profile, maps r=g=b to xy if the D65 illuminant (and then there module adapts that to the internal D50)
  • color calibration needs colours with a known reference point.