Research and development - White-Balance: auto -temperature correlation - tests - finding the optimum settings

I just made several modifications and added spectral colors

https://github.com/Beep6581/RawTherapee/releases/tag/pre-dev-github-actions

jacques

Some additional information.

I just added a commit (in wb_research), because I forgot (age?) compatibility in 5.9 disabling new features.

The limits I set that make “Camera” look “out” are arbitrary and easy to change (tint > 1.5 or t< 2800 or t > 9000). Be careful, however, not to enter settings (it is hard code) at the limits of the possible.

In the same way I trigger 2 passes if (a priori) the “camera” settings are at the reasonable limits of eliminating D50 and D65 - arbitrarily I chose 4000K (tropics…) and 7100K (overcast weather at Western latitudes. …).
Why 2 passes and not more. First it reruns the whole algo and starts resources. Secondly, it’s a bit like the cat biting its tail, because it looks (only a little) like “AWB temp bias” and I had to tinker around with AWB temp bias so that there was still a answer. But i will see if we can do better.

Another important point, I put by default - General colorimetry and not only Itcwb, Observer at 2°. It seems that RT behaves better - probably the Color Matrix should be generated with Observer 2°?.

Reminder: don’t forget to reset to neutral to take into account the new default settings;

jacques

I found and corrected 2 errors (mine more than 5 years ago), in the calculation of XYZ values from spectral data and “Blackbody” illuminant (tem < 4000°K).

  • The calculation of Planck’s formula was wrong.
  • The matrix product was incomplete.

This was to lead to bad results (correlation coefficient etc.) especially for Itcwb.

Jacques

5 Likes

I know I’ve said this many times, but I think the current version (commit d57c6cc) is worth trying.
I tried to solve the squaring of the circle (otherwise said the cat biting its tail).

I modified the algo in such a way that it can either work in 2 passes when the conditions are required or in a single pass. the checkbutton “Removed 2 pass algorithm” allows it.

I added in the GUI the deltaE of the patch between the image data and the spectral data (this assumes that there is enough spectral data).

You thus have 3 indicators (GUI) which allow (perhaps) to optimize the system. None is perfect, each has its relevance:

  • Correlation factor : best factor in final - but this assumes that Temp is in the correct range;
  • Patch chroma : optimizes the patch - temperature link, around a basic compromise. This assumes that the compromise is acceptable
  • deltaE : seeks the minimum difference between spectral data and those of the image - which assumes that the spectral data exist and are representative.

The 2-pass algorithm tries a compromise between deltaE and Correlation factor.

https://github.com/Beep6581/RawTherapee/releases/tag/pre-dev-github-actions

Jacques

In wb_research I just made several adjustments

After several hesitations I chose by default Observer 2° for all the colorimetry (general and Itcwb), this always looks better. But 5.9 compatibility is ensured by pp3

I simplified the GUI with removal of some settings (min size, ponderation).

The display of minimum data values is now more consistent. In addition I set a minimum number of pixels taken into account (this can in some cases change the result)

Last commit in “wb_research” 521382a, makes some adjustments (spectral colors, 2-pass threshold, etc.)

Jacques

Version: 5.9-339-gea648e5ea
Branch: wb_research
Commit: ea648e5ea
Commit date: 2023-05-02

The results are now very stable and the defaults good. Very little can be gained by changing the settings. Excellent results!

At first I thought that Observer 10° also produced very good (if sligthly more green) results but in overcast conditions and some other scenarios the green tint was to strong. So overall Observer 2° produces better results across a wide variety of samples.

Thank you for your ratings, whether on Pixls.us or PR.

Indeed after many tests I think that Observer 2° by default is better.

I made many modifications, in particular the number of spectral colors is now at 406. This element is essential to ensure the functioning of the algorithm.

Other modifications have been adjusted concerning both the thresholds where the 2-pass mode is engaged, or the taking into account of “Auto grey”
I just added a gamut control on the image data for the histogram, this can bring small changes.

I asked myself a lot of questions about images below 3000K. I was able to see that if I replaced the basic “color matrix” which is in D65, with the one found in the Exif of the dngs relating to stdA, the result was noticeably better. This is an observation, but it is almost impossible in the current code of RT to put 2 “Color Matrix”. Moreover the work to be done would be considerable, it would be necessary to seek this matrix for all the boxes… On the other hand how to choose. The impact is not only on Itcwb but on all colorimetry.

I just pushed these last changes as well in “wb_research” as in “whitebalanceopt” (PR).
Thank you if you can evaluate, then the question will arise of “merge” the PR in dev (and under what conditions at the GUI level).

https://github.com/Beep6581/RawTherapee/releases/tag/pre-dev-github-actions

Jacques

1 Like

.
@ Jacques
Un lien sur mon Drive. j’ai testé ton dernier RT-6643 de ce matin.
Une suite saisies-écran sur deux Raw (NEF) l’un en paysage l’autre en “intérieur”. Chaque série BdB de l’APN et Observer 2°, avec chacun des 4 choix
Le lien : Shadow Drive
Si tu le désires j’ai des NEF ISO élevés.
Chapeau bas pour tout ce travail.
A. B.

1 Like

@Cempoub

Merci Alain pour cette évaluation en français, et merci pour ton commentaire :slight_smile:

Oui, les NEF m’intéressent

  1. je vais évaluer Itcwb avec
  2. ils s’ajouteront à ma base de données.

Merci encore

Jacques

Ok pour les fichiers NEF.
Envoie-moi ton adresse.
Mon adresse mail: bernarda@tasgarth.net
puis tu auras le lien sur mon cloud “Shadow” d’ OVH pour les télécharger…
A+
Alain

I’m updating “wb_research” (commit 106cdd5), including the GUI - to enable ‘merge’ with dev. I also added some tooltips to (hopefully) make it easier to understand.

I started updating Rawpedia - in French, and in English. New paragraphs appear as:

  • Latest Improvements 05 2023
  • Data displayed in the GUI - limitations of interpretation;

But there is still a lot to do on Rawpedia regarding Itcwb
https://rawpedia.rawtherapee.com/White_Balance#The_Temperature_Correlation_Algorithm

jacques

1 Like

Hello Jacques!

First off, thanks a lot indeed for your efforts on improving RawTherapee :slight_smile:
I am a huge fan of this sofware which I use on a daily basis at work!

I have just tried your latest build (5.9-341-gb8703c705) on Windows 10, but I am not sure I am using it correctly :frowning:

At work, a colleague of mine has a Kenko color meter (KCM-3100).
He kindly helped me to measure the kelvin temperature which was around 5300.

Afterwards, I took 4 shots (NIKON D700 - iso 200, F8, 1/13 on a tripood):
1 - custom camera (automatic)
2 - 5260 k (manual white-balance). The closest to the Kenko (and to my eyes…).
3 - 3030 k (manual white-balance). It was completely wrong (on purpose!). There was a blueish cast.
4 - 9090 k (manual white-balance). It was again completely wrong. There was a yellowish cast, as a result.

I have tried the algorithm, at first, without changing anything to no avail. The cast persisted (3030 and 9090k).
Then I have also tried checking observer 10 instead of 2.

What I am supposed to do to get it working?
In the past days, I have also tried the same steps with a Nikon D850 to no avail (with previous builds of yours). Once again the manual white balance was wrong (on purpose).

Of course, I can share the NEFs, if needed…

Here is a video with all my steps (image 3 and 4):

Thanks a lot in advance!

@Silvio_Grosso
First, thank you for testing :slight_smile:

I think it is (perhaps) a matter of algorithm trigger thresholds, which I have set arbitrarily - therefore, to be checked with perhaps (or not) a solution. Can you provide the NEFs
Thank you

Jacques

Hello @jdc !

Here is the link to download from dropbox a ZIP folder with the 4 NEFs images relating to my test:
Nikon_D700_WB

My best regards and, once again, thanks a lot indeed for your work on RawTherapee all these past years! :slight_smile:

@Silvio_Grosso

I change the threshold settings when camera is “out”…

commit wb_research 21edc7c03

Probably it will need other adjustments…But the exercise is a bit curious

Best regards

Jacques

I have just pushed on wb_reserach and in the PR some changes to take into account these particular cases.

If the choice offered between 2 settings concerns a temperature close to or lower than 3000K the results are suspicious probably because of the color matrix (elaborated in RT - extract from Adobe DNG converter ) which is illuminant D65

The checkbox “Remove 2 passes algorithm”, allows you to switch (when possible) between the 2 choices - in the (majority) case where only one choice is offered, this checkbox is inactive (I haven’t found a way in this last case to hide it)

https://github.com/Beep6581/RawTherapee/releases/tag/pre-dev-github-actions

jacques

Version: 5.9-347-g002748143
Branch: wb_research
Commit: 002748143
Commit date: 2023-05-06

I accidentally (lucky for testing purposes) took this photo with the wrong WB settings today. Not intending to test itcwb. It clearly picks up camera wb and adjusts “around” it producing results wrong in the same direction as the camera wb.

For my other 100 or so shots itcwb refines in camera wb resulting in better WB. Even then though it seems that it stays to close to the camera WB. When the camera goes a bit cool so does itcwb? Perhaps the results are as they should but i get a bit suspicious when it always follows the camera, is this expected from the algo or is it just a coincidence?

When testing the files from Rawpedia the green foyer image is corrected but my image below isn’t.

2305061158_K-1_053.DNG (45.2 MB)


2305061158_K-1_053.jpg.out.pp3 (13.9 KB)

Hello Jacques,

Thanks again for this new build (5.9.348-gda9521f7c) which I have just tested on Windows 10
Now, the NEFs images pertaining to the Nikon D700 work all fine as regards the white balance. Great work indeed :slight_smile:

With this new build I also tested other images from a Nikon D850.
Once again, the white balance was completely wrong since I wanted to test the new algorithm. Sorry about that :slight_smile:
No previous build has ever been able to remove automatically (by way of the observer 2 - 10 options) the wrong white-balance.
Unfortunately, even this new build does not work fine with my images.
I must apply the other manual sliders available to get the correct white-balance (notably the AWB temperature bias slider).

Here is a screenshot of them (the first picture is correct; the second is wrong on purpose as regards the wb):

If you are interested here a link (Microsoft - OneDrive) to download the white flower (rosacea_fiore_wb) and the bike (moto_wb):

FLOWER_D850
BIKE_D850

My best regards!

Hello Jacques,

Just a different question :slight_smile:

At work, in the afternoon, I take some shots with a Nikon D850.
The light comes laterally from a window and no artificial light (lamps) is present. Very simple setup.
Even with the automatic settings from the camera (D850) once in a while the images have a slight blue cast. Nothing very damaging yet…

Since I usually put a white background it is very easy to fix them later on with RawTherapee (e.g. with the white color picker). Sometimes I have got even a color checker (Xrite) to improve the final colors.

In short, here is an image with this slight blue cast:
PETRI_DISH

Here is a link in case you are interested to take a look:
PETRI_DISH

I have tried today’s build but I am unable to fix them by only checking observer 2 and 10.

Thanks a lot, as usual, for your patience

Following your 2 sets of examples, I made a small improvement, still in case the “camera” values are “out”, by looking for another reference with “auto wb grey”.

Excuse my (very) bad english.

But before I comment on your remarks, a few detours on colorimetry, and that applied to Itcwb.
First thing, colorimetry is a very complex science and there is no right approach, you just have to open several software to see the differences. If I look at Darktable, how many changes in a short time, even if the approach and vocabulary are different from Rawtherapee.

How to solve the white balance problem (there must be the same problem with the different Cameras and their auto systems). The system has a very large number of unknowns and is theoretically totally indeterminate.
Indeed, and it is a mathematical law (which is apparently correct in the current state of science) where a perceived color is the matrix composition in the visible color range 350nm to 830nm of:

  • the real color is measured with a spectro – it is difficult to imagine walking with a spectro in nature and picking up 200 to 300 colors (flowers, sky, houses, etc.). So these values are globally indeterminate.
  • the illuminant - or illuminants - because for example when an image has parts in the shade and others in the sun this illuminant is different (I “neglect” the problem of artificial lights mixed with daylight ). The formulas of these (complex) illuminants are quite old and cannot foresee all cases related to altitude, latitude, pollution. Nevertheless it is an essential starting point, but we do not really know what this illuminant is (in spectral data). In addition, current climate change (increase in CO2 and air humidity, etc.) must significantly change the old formulas issued by scientists (1964). So these values are quite indeterminate.
  • Observer : it seems after our various tests that Observer 2° (1931) is more suitable than Observer 10° (1964) and this I think is related to the development of the “Color Matrix” (manufacturers and Adobe). Note that the choice made to take as a reference for the colorimetry (Cinema, standards…) of D65 (cloudy weather in the northern hemisphere) is to say the least curious and leads to convoluted calculations while the scenes in the sun are close to 5000K and that the internal colorimetric calculations (with chromatic adaptation, etc.) are made in D50. This choice (D65) is all the more critical when the illuminant of the scene is lower than D50. So here again a certain form of indetermination or at least we know that it is not perfect.

To sum up, the problem is almost completely indeterminate and it is necessary to make certain shortcuts (one can speak of false inferences), but it is necessary to find an acceptable workaround that works “almost” in 95% of cases. Aiming for 100% is utopia, whether in terms of the camera (auto or not) or the software (auto or not). Even AI couldn’t do it, too many unknowns and ultimately who can say “what’s good?”

To refine this approach, which is essentially mathematical and acts globally on the image, 2 factors can be taken into account:

  • locally retouch the white balance, for example for shaded areas, or for isolated artificial light. I had proposed this addition 5 years ago, in view of the apparent complexity, this was not retained. Nevertheless the use of “LA” and “warm/cool” modules allows an acceptable workaround.
  • consideration of human perception (eye-brain relationship). I will not go into detail on this complex subject which is treated differently in Darktable and Rawtherapee. Rawtherapee uses Ciecam (02 or 16) with chromatic adaptation (Cat02 or Cat16). This system - although not “perfect” - works 95% of the time. 5 years ago I proposed to “integrate” chromatic adaptation into Itcwb. Faced with the complexity and incomprehension, this was not retained. Today you have to activate “Color Apperance & Lighting” in “automatic symmetric” mode and adjust “Temperature Viewing conditions” (which must be close to that of White Balance) and the 2 chromatic adaptations. As soon as the temperature found is different from 5000K, it is desirable to correct with this chromatic adaptation (image too cold or too hot.)

Next will come…

Before continuing on Itcwb, another detour using “Pick”. This command assumes (algorithm) that the reference gray is perfect (R=G=B or “a” and “b” from Lab to zero). Which is not the case in the Colorchecker24… Just try each of the gray boxes to see the difference. On the other hand once done this assumes the linear colorimetric extrapolation laws - which is not the case. In addition, as before, this command performs a mathematical correction and does not take human perception into account. Nevertheless, it is often an acceptable approach. Certainly it’s easier (less efficient) than a spectro (and 200 colors to measure), but which will systematically include a Colorchecker in each shot :slight_smile:

Jacques