White Balance
Introduction
Digital images generally consist of a mixture of the three primary colors: red, green and blue. For various reasons which you can read about in-depth elsewhere, the red, green and blue values which serve as the starting point in any raw photo development program need to be corrected in various ways before they resemble the photographed scene. One of these corrections is performed by adjusting the white balance - ensuring that neutral-colored (white) objects in the photographed scene still appear neutral on the photograph. Adjusting the white balance affects all colors, though it is easiest to discern whether the white balance is correct if an object you know to be of a neutral (white, gray) color looks non-neutral.
White balancing works by multiplying each of the primary colors by a different amount, until a satisfactory result is reached. In order to make this operation more human-friendly, instead of operating on the three multipliers directly, the user is presented with an abstraction in the form of a temperature slider which adjusts colors along a blue-yellow axis, and a tint slider which adjusts them along the magenta-green axis.
A neutral color is one whose red, green and blue values are equal. For example, R=G=B=65% and R=G=B=90% are both neutral, the former being darker than the latter. You can tell whether the white balance of a spot which should be neutral is correct by checking whether that spot's RGB values match, or whether the a* and b* values in the L*a*b* color space match, or whether the RGB indicator bars under the main histogram are directly over each other. You can do this even if you have a very miscalibrated monitor. Your perception of color changes depending on the color of the surroundings and of the illumination in your room, so don't always trust your eyes - verify using the method described above.
Having an incorrect white balance results in the image having a color tint, typically warmer (orange) or colder (blue). Some people use this for creative effect, however there are various tools and operations which rely on the assumption that the white balance of the image is correct (for example highlight recovery in the Exposure tool, skin targeting in the Contrast by Detail Levels tool, sky targeting in the Wavelets tool, the CIECAM02 tool), so you should not misuse the white balance tool to create a color cast for artistic effect but rather use it to ensure that neutral areas remain neutral, and then use Color Toning or any of the other tools to render a creative color tint.
The white balance tool can be turned on/off. When off, the multipliers are set to R=1 G=1 B=1 when working with raw files. This can be useful for diagnostic purposes or when working with UniWB images.
Interface Description
Method
Camera
- Takes the white balance used by the camera. If you shoot only in raw (so no raw+JPG), put the white balance settings of your camera on auto. This should generally give good results.
Automatic
- RGB grey
- Automatically corrects the white balance, by assuming that the average color of the scene is neutral gray. Works well for a wide range of scenes, and can be a good starting point for manual adjustments.
- Temperature correlation
- Provides a generally better color balance than auto “RGB grey". The algorithm is based on the best correlation (Student's test) between the colors of the image and an array of 200 spectral reference colors.
- This algorithm may give erroneous results:
- If the illuminant does not have a CRI (Color Rendering Index) close to 100, e.g. "Underwater", "Fluorescent", "Led" lighting conditions may give bad results.
- Some DNG-type files obtained after conversion with a DNG or other converter.
- If the shooting conditions are extreme (very low luminance values, etc.).
- The GUI displays the correlation value:
- A value of 1000 means either that calculation is not performed again and that the previous results are used, or that the algorithm has failed to compute a result in which case T=5002 is displayed.
- Values less than 0.01 are good.
- A description of the Itcwb algorithim in French can be found here algorithm
- RGB grey
Custom
- Set your own color temperature and green tint by moving the two sliders and/or using the Spot WB tool.
Principe de l'algorithme Temperature correlation - (Itcwb Iterate temperature correlation white balance):
Contrairement à la majorité des algorithmes de balance des blancs qui sont basés sur les gris, celui-ci est basé sur les couleurs. De manière simplifiée l'algorithme compare un panel majoritaire de couleurs de l'image et des couleurs de référence à données spectrales.
Origine de l'algorithme
C'est une simple lecture d'un résumé de recherche non documenté précisant 3 phases qui m'a lancé dans la mise au point de l'algorithme :
- a) comparaison xyY
- b) données spectrales
- c) histogramme des couleurs
- c'est sur cette base que j'ai mis au point l'algorithme que je vais décrire ci-après, donc à l'origine ni algorithme de principe, ni code,...
Sa pertinence est fondée sur:
- le choix des couleurs de l'image : échantillonnage, prise en compte des couleurs dominantes (peau, ciel, végétaux...)
- la prédétermination de certains paramètres de base pour les calculs (température camera, teinte,...)
- le choix des multiplicateurs de canaux RGB et leur calcul en fonction de la température de l'illuminant
- le principe mathématique de calcul des valeurs XY des couleurs de référence (données spectrale), par une formule « exacte » et un échantillonnage des données spectrales à 5nm. Matrice[Couleur vue] = Matrice[illuminant] * Matrice[couleur] / Matrice[Observer 2°]
- L’itération multiple des calculs en prenant en compte à égalité l'équilibre vert-magenta et rouge-bleu.
- Des calculs rigoureux si l'illuminant est avec un CRI (Color Rendering Index) proche de 100, donc illuminant proche de Daylight dans la limite 4100K – 12000K ou Blackbody de 2000K à 4100K.
- La corrélation statistique via un test de Student.
Origine et nature des 200 couleurs spectrales de référence :
- soit elles proviennent de données que l'on trouve sur le web pour les fleurs, feuillages
- soit elles proviennent de la ColorChecker24 ou d'autres grilles
- soit elles proviennent de la mire d'étalonnage 468 que j'ai élaborée pour l'étalonnage il y a quelques années
- soit elles sont élaborées à partir de l'utilitaire Colorlab (Logo Gmbh)
- ces couleurs sont réparties à peu près également sur toute la palette de couleurs (Rouge, Orange, Jaune, Vert, Cyan, Bleu, Magenta...)
- ces couleurs sont également réparties entre neutres ou proches des gris, peu saturées, pastels, saturées
- la luminance n'a que peu d'importance car la comparaison se fait sur la composante chroma
Principes généraux :
- en amont on calcule à partir de données situées avant dématricage 3 tableaux red, green, blue pour 1 pixel sur 10 de l'image - horizontalement et verticalement (il est possible de changer cette valeur si nécessaire pour plus de précision). Les valeurs sont ajustées afin qu'elles soient dans l'amplitude 0..65535.
- puis on passe à une procédure commune aux 2 algorithmes « autowb » via le calcul des multiplicateurs de canaux RGB, qui oriente ensuite soit sur « Itcwb », soit sur « wb auto» ("Wbauto")
- « Wbauto » passe les paramètres à "Itcwb" avec les premiers paramètres réellement importants : température de référence – celle présente dans les données Exif (camera) et celle de la teinte également présente dans les données Exif, mais dont les valeurs sont bornées à 0.77 et 1.30 – (il n'y a pas d’illuminant Daylight ou Blackbody au delà des ces limites arbitraires et donc les calculs seront fantaisistes ou faux...).
Algorithme simplifié « Itcwb » proprement dit :
Première étape :
- calcul des multiplicateurs RGB pour chaque température entre 2000K et 12000K et de la teinte
- calcul des valeurs XY à partir des 200 données spectrales pour chaque température
- choix d'une plage de données pour les températures par rapport à la référence
- calcul des valeurs xy sous la forme d'un histogramme : positionnement de ces couleurs parmi 158 en privilégiant les données les plus répandues (peau, ciel,...) pour chaque température
- tri ascendant de ces données en nombre
- pour les données majoritaires, calcul des valeurs chromatiques de l'image
- choix des couleurs de référence parmi les 200, par utilisation d'un deltaE chroma.
- Calcul des valeurs RGB de référence en fonction de la température de référence
Deuxième étape :
- calcul pour chaque couleur de référence choisie, des valeurs XY en fonction de la température et de la teinte
- calcul des valeurs RGB de l'image à partir des couleurs choisies à l'aide des multiplicateurs RGB,
- premier calcul de la corrélation Student
- pour chaque plage de teinte et de température, calcul des multiplicateurs de canaux , calcul des XY à partir des bonnes données spectrales
- calcul des coefficient de corrélation en fonction de green (teinte)
- tri de ces valeurs
- optimisation afin de déterminer les bonnes valeurs de température et teinte.
- Passage de ces paramètres à « wbauto »
- affichage des résultats et prise en compte dans Improccoordinator.cc
Pick
When you click on the Pick button
(shortcut: w), the cursor changes into a pipette when it's over the preview. Click on a neutral area to set the correct white balance for the whole image based on the clicked area.
Pick a spot which should have a neutral tone - gray or white. This spot should not be clipped in any of the three channels, as clipping means that information from the clipped channel is missing. As far as white balancing is concerned, "white" does not mean R=100% G=100% B=100% as that would be clipped, but instead means a shade of gray - even a very light one, but still one without any clipping. The picked spot should also not be black, as black means that insufficient data was captured for that area, and so a correct white balance calculation cannot be performed.
You can use the picker multiple times on different places in the photo until you find an ideal spot. Use the Size drop-down box to change the size of the pipette.
This tool can be used as well inside a detail window. Right-click to cancel the tool and to get the regular cursor back.
Temperature and Tint
The temperature slider adjusts colors along the blue-yellow axis. Moving it to the left makes the image cooler (bluish); moving it to the right makes it warmer (yellowish).
The tint slider adjusts colors along the magenta-green axis. Moving it to the left makes the image more magenta; moving it to the right - more green.
Blue/Red Equalizer
The red/blue equalizer allows to deviate from the normal behavior of "white balance", via increase or decrease of the ratio between red and blue. This can be useful when shooting conditions are far from the standard illuminant, e.g. underwater, or are far from conditions where calibrations were performed, for which the color matrices in the input profile are unsuitable.
AWB Temperature Bias
The auto white balance temperature bias slider allows you to specify how much the automatically-calculated temperature should deviate. Use this if you would like the automatically-calculated white balance to be cooler or warmer.
White Balance Connection to Exposure
The white balance is described in temperature and tint, but when working with raw images it will be translated into weights of the red, green and blue channels. The weights will be adjusted so that the channel with the smallest weight reaches clipping in the working space (usually ProPhoto RGB) when the raw channel is clipped. In other words, with exposure set to 0.0 and no highlight recovery enabled the full visible range is fully defined by the raw backing. As white-balancing changes the weights you may see a slight exposure change if you make drastic changes to white balance.