White Balance

White Balance

1 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.

2 Interface Description

2.1 Method

  • Wb-camera.png 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.
  • Wb-auto.png 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
  • Wb-custom.png Custom
Set your own color temperature and green tint by moving the two sliders and/or using the Spot WB tool.
  • Light source presets
    • Wb-sun.png Daylight (Sunny)
    • Wb-cloudy.png Cloudy
    • Wb-shade.png Shade
    • Wb-water.png Underwater
    • Wb-tungsten.png Tungsten
    • Wb-fluorescent.png Fluorescent
    • Wb-lamp.png Lamp
    • Wb-led.png LED
    • Wb-flash.png Flash


2.2 Principle of the Temperature Correlation algorithm (Iterative temperature correlation white balance or Itcwb ):

Unlike the majority of white balance algorithms based on gray tones, this one is based on color. Put simply, the algorithm compares a large number of sample colors in the image with a set of reference colors and their associated spectral data.

2.2.1 Origin of the algorithm

I decided to develop this algorithm after reading an unpublished research summary, which divides the process up into 3 phases:

  • a) xyY comparison
  • b) spectral data analysis
  • c) color histogram analysis

These phases form the basis of the algorithm described below, which was developed from scratch and is not based on any existing algorithms or code.

2.2.2 The performance of the algorithm depends on:

  • The choice of colors in the image obtained by sampling and selecting the dominant colors (skin, sky, plants etc.).
  • The determination of certain parameters, which will be used as the basis for the calculations i.e. camera white-balance temperature, which acts on the red and blue components and tint, which acts on the magenta and green components, etc.
  • The choice of the RGB channel multipliers and their calculation based on the temperature of the illuminant.
  • The calculation of the XY values of the reference colors (spectral data), using an "exact" formula and samples of spectral data at 5nm. Matrix [Color seen] = Matrix [illuminant] * Matrix [color] / Matrix [Observer 2°].
  • Multiple iteration of the calculations taking into account, in equal proportions, the balance between green-magenta and red-blue.
  • Rigorous calculations if the illuminant has a CRI (Color Rendering Index) close to 100 i.e. illuminant close to Daylight in the limit 4100K - 12000K or Blackbody from 2000K to 4100K.
  • Statistical correlation using a Student's test.

2.2.3 Origin and nature of the 200 reference spectral colors:

  • Data found on the web for flowers, foliage.
  • A ColorChecker24 or other color patches.
  • The 468 calibration chart that I developed for calibration a few years ago.
  • The Colorlab utility (Logo Gmbh).
  • These colors are distributed almost equally over the entire color palette (Red, Orange, Yellow, Green, Cyan, Blue, Magenta…).
  • These colors are also sorted into neutral or close to gray, slightly saturated, pastel and saturated.
  • The luminance has little significance because the comparison is made on the chroma component.

2.2.4 General principles:

  • Using the RGB values prior to demosaicing, 3 tables are generated (Red, Green, & Blue) for 1 pixel out of every 10 in the image (horizontally and vertically). It is possible to change this value if necessary for more precision. The values are then adjusted so that they are in the range 0 to 65535.
  • Then we switch to a procedure called "autowb", which is common to both automatic white balance algorithms. It calculates the RGB channel multipliers, and passes on the values to either to "Itcwb" or "rgbgray".
  • The parameters that "wbauto" passes on to "Itcwb" include the important reference temperature (the value present in the Exif camera data) and the tint (also present in the Exif data), whose values are limited to the range between 0.77 and 1.30. There is no Daylight or Blackbody illuminant beyond these arbitrary limits and any calculations would therefore be fanciful or false.

2.2.5 Simplified "Itcwb"algorithm:

2.2.5.1 Step one:
  • Calculate the RGB multipliers for each temperature between 2000K and 12000K and for the tint.
  • Calculate the XY values from the 200 spectral-data values for each temperature.
  • Select a temperature data range relative to the reference.
  • Calculate the xy values in the form of a histogram and select from among the 158 possible values, the most commonly used colors (skin, sky, etc.) for each temperature.
  • Sort the data in ascending numerical order.
  • For the most frequently occurring data values, calculate the chromatic values of the image.
  • Use the deltaE chroma values to select the reference colors from the 200 available possibilities.
  • Calculate the reference RGB values as a function of the reference temperature.
2.2.5.2 Step two:
  • Calculate the XY values for each selected reference color as a function of temperature and tint.
  • Calculate the RGB values of the image from the XY values using the RGB multipliers.
  • First calculation of the Student correlation.
  • For each tint and temperature range, calculate the channel multipliers and the XY values from the corresponding spectral data.
  • Calculate the correlation coefficient as a function of the color green.
  • Sort these values.
  • Optimize the values to determine the correct temperature and tint values.
  • Send these parameters to "wbauto”.
  • Display the results and update Improccoordinator.cc.

2.3 Pick

This tank wagon was the whitest object in the scene. We can tell that the white balance is wrong because the RGB levels are not equal, and the RGB indicator bars directly under the histogram are spread apart.
Picking the white balance off the side of this tanker, which we know to have been the whitest object in the scene, adjusts the colors across the whole image such that the RGB levels in that spot are now equal.

When you click on the Pick button Color-picker.png (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.

2.4 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.

2.5 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.

2.6 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.

3 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.