White balance settings & calculations

DT 3.8.0 on debian with Fujifilm x-pro2 images, scene referred workflow

I have problems understanding how the white balance is set.

I took 25 photos of the same location for 1hr, 30mn before sunset until 30mn after sunset. The camera was on auto white balance.

When I look at the white balance with exiftool, it only shows auto white balance

exiftool burrard-bridge-20220109-1608-001.raf|grep 'hite'
White Balance                   : Auto
White Balance Fine Tune         : Red +0, Blue +0

But DT calcs it to: 4393 in color calibration

and the last image:

exiftool burrard-bridge-20220109-1708-025.raf|grep 'hite'
White Balance                   : Auto
White Balance Fine Tune         : Red +0, Blue +0

But DT calcs it to: 4243 in color calibration

but when I check it with rawtherapee, it shows:

1st image: 5585
2nd image: 5415
  1. How does the white balance gets calculated for as shot?
  2. How do I set the white balance in DT to ā€œas shot by the cameraā€?

Thanks

Contrary to popular belief, white balance applied to an image is not a color temperature, it’s three multipliers, one for each channel, that make a pixel that is supposed to be white, white.

The calculated color temperatures in raw processors is an approximation, with at least one discontinuity in the equation. The actual color temperature of a light in the scene can really only be measured in the scene; once the image is encoded to RGB, reverse-engineering it is a coarse approximation.

So, I took a RAF I’d downloaded for a PlayRaw and went looking for the multipliers. grepping for ā€˜WB’, I got this:

$ exiftool -G  DSCF1505.RAF |grep WB
[RAF]           WB GRB Levels Standard          : 302 364 862 17 302 615 510 21
[RAF]           WB GRB Levels Auto              : 302 426 739
[RAF]           WB GRB Levels                   : 302 426 739

So, ā€˜GRB’ means the values are in green,red,blue order, and the ā€œWB GRB Levelsā€ apparently are the ā€œas shotā€ numbers. To get the multipliers, the R and B values need to be divided by the G value, so:

R = 426/302 = 1.410596
B = 739/302 = 2.44702
G = 302/302 = 1.000 (for completeness)

G is the anchor, and white balance is actually an adjustment of R and B so that for a white pixel, R=G=B.

exiftool does a convenient thing, in the Composite tags it provides a Red Balance and Blue Balance where the calculation is done for you:

$ exiftool -G  DSCF1505.RAF |grep Balance
[MakerNotes]    White Balance                   : Auto
[MakerNotes]    White Balance Fine Tune         : Red +0, Blue +0
[Composite]     Blue Balance                    : 2.44702
[Composite]     Red Balance                     : 1.410596

Now, for your questions:

It is widely assumed that camera manufacturers have their own unknowable algorithms for calculating as-shot white balance multipliers. There are good alternatives in the open research, with the fundamental one being the so-called ā€œgrey worldā€ algorithm, look it up…

darktable has selectable presets, one of them is ā€˜as-shot’:

https://docs.darktable.org/usermanual/3.8/en/module-reference/processing-modules/white-balance/

I believe this preset will use the WB GRB Levels numbers from the metadata, I’m too lazy to inspect the code to confirm… :laughing:

Anyway, more than you probably wanted to know…

10 Likes

Color Calibrations temperature reading will not be the same as what your camera reports. If it looks good, go with it.

1 Like

Its explained in detail here…

In CC module they are not WB temp…it is an approximation in CAT space of the CAT you choose…

You can use legacy…old WB module or
You can use modern…set old module to camera reference and use CC module

If DT correctly reads your WB coefficients and they are accurate it will open as shot.
You can use the pipette on the image or a reference to select a neutral grey

This you likely already know…

I find sometimes running CC it will be bang on and other times it can overcorrect. If so I toggle to custom and drop the chroma a bit…this starts to back off the effect and let back some of the corrected color cast… You can do this to taste…

There are some new features on the horizon for exposure and color matching images but they have not been merged…

EDIT:

This one is a thorough treatment and provides an illustration of using CC for images with multiple WB/illuminants

Don’t worry about those temperature numbers. Different software use different formulas (you’ll also see that if you switch darktable to the legacy chromatic adaptation method, and simply use the white balance module (without color calibration), it will give you a third number, because that’s a different beast altogether.

For example (on a random photo), using the ā€˜old’ white balance module (without color calibration), with as shot white balance shows 5242 K:
image

And to show the coefficients:
image

Now, if I switch to modern chromatic adaptation (white balance set to camera reference, enabling color calibration):
image

Showing the temperature: 4260 K:
image

But the photo’s colours look pretty similar:
legacy:
image

modern:
image

2 Likes

And just to complicate things a bit more, colour temperature is only valid for black body radiation.

So for all modern light sources like LED or fluorescent lights, colour temperature is at best an approximation and at worst, wrong. Sunlight and incandescent lamps are a good approximation, but e.g. outdoors in the shade you are already in trouble (and that’s before you look at what’s reflecting the light on your subject, leaves or a red brick wall will not help)

So in photography, white balance based on colour temperature is nothing more than a handy shortcut to describe the required correction in terms we think we understand. So theres’s no reason to worry about different programs giving different values (unless, of course, you have to mach colour between those programs. Then, good luck :grinning: )

2 Likes

(This is not for you, @rvietor, I know that you know :slight_smile:)
The note quoted above is why darktable’s color calibration module sometimes display the CCT as invalid, which then confuses users who are new to the module, thinking somthing is wrong (either that they made a mistake or that there’s a bug). See darktable 3.8 user manual - color calibration :

When the CCT is followed by ā€œ(invalid)ā€, this means that the CCT figure is meaningless and wrong, because we are too far from either a daylight or a black body light spectrum. In this case, you are advised to use the custom illuminant. The chromatic adaptation will still perform as expected (see the note below), so the ā€œ(invalid)ā€ tag only means that the current illuminant color is not accurately tied to the displayed CCT. This tag is nothing to be concerned about – it is merely there to tell you to stay away from the daylight and planckian illuminants because they will not behave as you might expect.

4 Likes

I think that most cameras just use a bunch of simple heuristics (eg try to estimate WB by white patches, compare with known light source profiles, select the most likely matches) then adjust to prevalent consumer taste (make it warmer, most of the time; I wonder if there is a historical trend?).

Unless carefully measured on the scene, I would just treat what the camera thinks about WB as a guideline to be adjusted like any other aspect of the image.

2 Likes

That’s a good way to treat it, IMHO. I let my camera do auto WB all the time, and it works okay for my proof images. But, I reserve the right to change it if necessary. To that end, for serious work, I shoot a ColorChecker image in the light of the scene, that way I have a white patch for WB adjustment and the color patches if I want to later make a camera profile that is custom to the scene…

Oh here’s one to hurt your head; if you’re making such a camera profile, if you DON’t white-balance the target shot before making the profile, you can have the profile also do your white balance, as a chromatic operation rather than using the nasty multipliers… :crazy_face:

1 Like

I think that most people care about white balance because the image looks weird when it is off, so the best practical strategy is learn how to recognize and address that.

I usually try to get faces right first (they look creepy when too red, or a blue/green cast), for which one degree of freedom (color temperature) usually gets one reasonably close, except for multiple light sources etc. Then go to Custom illuminant for 2 degrees of freedom for other objects, and if that still fails, deal with the 3x3 matrix in Color calibration.

For me the most tricky situations are faces illuminated directly from one side and then reflected other colored light from the other (eg in a forest). But as I gain experience with Color balance RGB and masks I now manage to get to close to how I want it to look.

All this started because of taking photo of a bridge at sunset and then later past the sunset into the beginning of the night.

I would have expected that during the sunset, the white balance would become warmer and as the light fades into the night, the white balance would become colder. Which is why I started to ask the question.

Plenty more to learn…

Thanks

Yeah, sunrise and sunset pose white balance challenges. Since most of my serious imaging occurs during these times, I tend to just not worry about it and let the camera do it’s thing…

Although, I might go out one morning, set the ColorChecker on a bench in the open, and take a series of shots of it as the morning progresses from twilight to full daylight. Something to do in post-retirement… :laughing:

3 Likes

The scopes can be very helpful in evaluating these things. I think the waveform is awesome for looking at the regional intensity and wb variations in the image and guiding the corrections.

1 Like

The color of the illuminant patch might help as it would change accordingly but maybe that it too subtle to see the difference. You could also go by the numbers using the values from the hue/chroma sliders. You can bring them up by selecting custom or often they are presented if you don’t have a standard wb. You could monitor how these are changing. Looking at your waveform and parades could also reveal changes over time perhaps again if they are not too subtle…

Any "good’ dt tutorials on how to use the scopes vs the histograms?

Thanks

These aren’t DT specific, so any resource that explains them in a relatively tool neutral should be fine.

Likely the best ones are for Davinci Resolve or video apps…but basically the wave forms show you values of each color channel across the x-axis of your image. Looking at the channels if it shows white then the values of RGB have overlapped…. So you can use this to assess the ratio of RGB in your image and the overall intensity from the height of the signal…the parades pull the channels apart and put them side by side so you can adjust them and balance the image……

Pull up one of your images and go to the different wave form views…then open the rgb curve module and play with the individual curves so that you can see how the scopes behave….

As I said above most will be video centric but the operation is exactly the same for stills…I don’t think anyone has done a DT video specifically about scopes…

Andy does a nice job on his videos and he has one… @Andy_Astbury1

Its demonstrated on RT but essential again as I said directly relatable…

3 Likes

Actually, in darktable it’s possible to get a view along the y-axis, too:
https://docs.darktable.org/usermanual/3.8/en/module-reference/utility-modules/shared/scopes/

Clicking the second-to-leftmost button on the panel toggles between a horizontal and a vertical waveform. In the vertical waveform, the y-axis of the plot represents the y-axis of the image, and the x-axis represents the distribution of pixels by lightness. The vertical waveform can be useful for portrait-format images, or simply to understand an image in a different way.

1 Like

I was aware of that. Was trying to keep it simple… I have toggled that on a few times but my brain isn’t wired for it… :blush:

@foto You can also use the vectorscope as a nice tool to assess compare and correct WB…

Like all the tools you will come up with your own workflow using these…

Ihttps://www.youtube.com/watch?v=74wNG3wFdtU&list=RDCMUCsljz6Nw6afi2f6I5DJlBdA&index=1

2 Likes