White Balance: Difference between revisions

From RawPedia
Jump to navigation Jump to search
(Added intro and moved the 'creative effect' paragraph up.)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Digital images generally consist of a mixture of the three primary colors: red, green and blue. For various reasons 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 scene photographed. One of those corrections is based on setting the correct white balance - making things which should be white (or neutral gray) appear white (or neutral gray), otherwise they will have a color cast. White balancing works by multiplying each of the color primaries by a different amount, until you get a satisfactory result. In order to make this operation more human-friendly, the multipliers are controlled by easier to understand temperature and tint sliders (and a red/blue equalizer for photos taken in unusually 'cold' or 'warm' environments - read about it below), and you can have them automatically set the correct values by using the "Spot WB" pipette on an area of the photo which should have a neutral color.
<div class="pagetitle">White Balance</div>


Having an incorrect white balance gives the image a color tint, typically warmer (orange), or colder (blue). Some people use this for creative effect. There are various tools and operations which rely on the assumption that the white balance of the image is correct, for example highlights recovery, skin or sky hue targetting, etc. You should not make creative color tints using the white balance tool, but rather use it for making white what should be white, and then use any of the other tools in RawTherapee to add a desired color tint for creative effect.
== 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 ==
== Interface Description ==
=== Method ===
=== Method ===
White balance can be set in different ways: Camera, Auto, Custom, or a host of presets for different light sources.


* [[image:Wb-camera.png]] Camera
* [[image: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.
*: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.
 
* [[image:Wb-auto.png]] Automatic
* [[image:Wb-auto.png]] Auto
** 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.
**: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 [[White_Balance/fr#Principe_de_l.27algorithme_Temperature_correlation_-_.28Itcwb_Iterate_temperature_correlation_white_balance.29: |algorithm]]
* [[image:Wb-custom.png]] Custom
* [[image:Wb-custom.png]] Custom
: Set your own color temperature and green tint by moving the two sliders and/or using the Spot WB tool.
: Set your own color temperature and green tint by moving the two sliders and/or using the Spot WB tool.
* Light source presets
* Light source presets
** [[image:Wb-sun.png]] Daylight (Sunny)
** [[image:Wb-sun.png]] Daylight (Sunny)
** [[image:Wb-cloudy.png]] Cloudy
** [[image:Wb-cloudy.png]] Cloudy
** [[image:Wb-shade.png]] Shade
** [[image:Wb-shade.png]] Shade
** [[image:Wb-water.png]] Underwater
** [[image:Wb-tungsten.png]] Tungsten
** [[image:Wb-tungsten.png]] Tungsten
** [[image:Wb-fluorescent.png]] Fluorescent
** [[image:Wb-fluorescent.png]] Fluorescent
Line 26: Line 45:
** [[image:Wb-flash.png]] Flash
** [[image:Wb-flash.png]] Flash


=== Spot WB ===
 
When you click on the Spot WB button [[image:Gtk-color-picker.png]] (shortcut: '''w'''), the cursor changes into a pipette when it's over the preview. Click on a gray or neutral area to determine the correct white balance. The gray/neutral area may not be clipped, otherwise readings will be off. You may use the picker several times on different places in the photo, until you find a spot that leads to a suitable reading. 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.
===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.
====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.
 
====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.
 
====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.
 
====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.
 
====Simplified "Itcwb"algorithm:====
=====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.
 
=====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.
 
=== Pick ===
 
[[File:White balance 1 before.png|thumb|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.]]
 
[[File:White balance 1 after.png|thumb|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 [[File: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.


=== Temperature and Tint ===
=== Temperature and Tint ===
Moving the Temperature slider to the left makes the image cooler (bluish), moving it to the right makes it warmer (yellowish). Moving the Tint slider to the left makes the image purplish, moving it to the right greenish.
 
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 ===
=== Blue/Red 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, where the matrices or ICC profiles are unsuitable.


== White balance connection to exposure ==
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.
The white balance is described in temperature and tint, but will for raw images internally 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 balance changes the weights you may see a slight exposure change if you make drastic changes.
 
=== 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.

Revision as of 08:51, 28 June 2021

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

  • 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


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.

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.

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.

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.

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.

Simplified "Itcwb"algorithm:

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

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.

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.