Hello,
Just the results of investigating how white balance works. I'm publishing this in case it's useful to someone (it's pretty advanced and technical though).
Motivation
I've been trying to profile read/dark noise, but found that white balance affects the noise level. I wanted to calibrate the noise so I don't need to shoot dark frames, but generate them automatically from a ISO/Temperature model. I can't adapt my model without being able to interpolate different WB's, and to do that I need to set specific RGB ratios.
What I Found
WB is a pretty complicated subject. Luckily I have a camera that let's me modify a standard WB to one of 360 other settings. There doesn't seem to be a simple formula to convert between RGB gain settings and WB/colour temperature, so I have to make do with tables of available values.
The modify WB setting isn't even documented for my camera, but there's some good info in the DNG standard that explains WB in general.
The camera allows 19 settings on two axis for modify a base WB.
The horizontal axis is 0 to 9 Blue, to 0 to 9 A (which is coloured Red)
The vertical axis is 0 to 9 Green to 0 to 9 Magenta
Increasing B reduces K (colour temperature), increasing A increases K
Increasing G reduces K a bit, increasing M increases K a bit
The lowest K is at b9,g9, the highest K is at a9,m9
Moving towards Blue makes the image bluer, moving towards A makes the image redder.
I made a table of R/G/B gain values and colour temperature (K) values, by shooting at various settings and reading the gain values from the .cr2 (RAW) file using exiftool(-k).exe. Just look for the White Balance As Shot tag.
Daylight
R G B K
0,0 1557 937 1785 4963
b9,0 1270 897 2155 3779
b1,0 1517 935 1831 4787
a1,0 1600 940 1739 5157
a9,0 1956 936 1389 7336
0,g9 1442 1070 1636 4910
0,g1 1544 951 1770 4957
0,m1 1567 923 1803 4970
0,m9 1658 814 1932 5017
b9,g9 1204 1034 1946 3742
a9,m9 2137 810 1461 7422
Tungsten
R G B K
0,0 1056 745 2600 3180
b1,0 1034 739 2628 3113
b9,0 837 684 2939 2643
Reading This Table
The first column is the custom settings value. Next are three numbers representing the analog gain on each colour of the image. Then is the colour temperature that is supposed to be.
For example Daylight which is normally K=4963 can be modified from K=3742 to K=7422.
You can see how K affects RGB here
https://academo.org/demos/colour-temperature-relationship/It's a javascript widget that lets you select K and render it's colour, and display equivalent RGB values. K is orange for low values, then white around 6500, finally turning to blue at high values.
Remember that gain settings are just the opposite of the K->RGB colours. For a low K like 3180 (Tungsten, which looks yellowish), you need to increase the gain of Blue dramatically to get a white colour, as you can see in the table, the gain for blue (2600) is much greater than the other colours, such as Red (1056).
What does the Green/Magenta axis do?
This one was pretty easy. First of all, Green/Magenta are on opposite sides of the colour wheel, meaning Magenta is just a colour with Green subtracted from it, in other words this is just plus or minus Green. If you look under Daylight at g9 (1070) and m9 (814) and subtract them, you get 256. That means each step of Green is just 256/18 added to the base value. This turns out to be approximate.
What is the A on the horizontal axis?
A may stand for Aqua or Azure, it makes no sense as blue's opposite is yellow and I can't think of an orangish colour that starts with A. The B/A axis might refer to Lab colour, but that doesn't work because a is green to magenta and b is blue to yellow