Faced with all these indeterminacies, I made several choices to reduce the complexity
- analyze 237 colors of the image (instead of all). Of these 237 colors, only the xy (xyY) values are kept, they cover the entire visible spectrum.
- choose a patch among these colors which is the most representative. After many tests this patch is made up of the 20 to 70 most represented colors. Their impact is weighted to take into account their frequency.
- To develop this patch you must start from a starting base. It’s either:
“Camera” values (temperature and tint) by eliminating tint values too different from 1.
“Automatic WB grey” values if “Camera” values are probably “out” (tint > 1.5, temperature < 3300K or temperature > 7700K) and if “Auto WB grey” values are not themselves “out”
From this patch and these starting points, we calculate the corresponding spectral data 20 to 70 among 406.
From these various data we vary “temp” (± 200K approximately,) and “tint” (green), to find the best correlation.
If the found correlation temperature of is in the range 4000K, 7000K (most common daylight), keep the result and run a single pass. If the values found are < 4000K or > 7000K, a 2nd pass is performed with a new value located between 4500K and 5300K. The algorithm is restarted, new starting values, new patch, new spectral data. The choice is made by optimizing the product deltaE and Correlation factor.
In the case of 2 passes, you can select either one with the “Remove 2 passes algorithm” checkbox. The number of passes, the size of the patch, the deltaE, the correlation factor, appear in the GUI.
Due to the increased number of spectral data (200 to 406), the noise reduction (median 3x3) applied to the image data, the number of passes, the processing time has increased significantly, passing (depending on the images and the machine) from 100ms to 500ms. So, one can hardly consider a “longer” treatment.
As I mentioned, this system works correctly in the majority of cases, but it fails (like all systems…) in a few cases. Aiming for 100% is an utopia.
I updated the documentation on Rawpedia (simplified), and I think that apart from a few changes - especially at the GUI level, this version is almost complete. Thank you to everyone who contributed to this significant improvement
https://rawpedia.rawtherapee.com/White_Balance#The_Temperature_Correlation_Algorithm
And the last version
https://github.com/Beep6581/RawTherapee/releases/tag/pre-dev-github-actions
Thank you again
Jacques