# White Balance

## What is white color temperature

A “white” color has different chromatic characteristics, depending on its “temperature”. That temperature is traditionally expressed in Kelvin and corresponds to light, emitted by an ideal black body radiator, when heated to that temperature. Think of it as the color of a burning stick of wood at a campsite or a “red-hot iron” that looks more yellow when it actually melts in a furnace.

When a scene is illuminated by “white” color there's usually color correction needed to bring the “true” colors out. The “true” in this sense is an approximation of how our brains perceive colors during daylight, which is around $6000°K$.

For our purposes, we are using individual color channel gains to compensate for a given temperature. Lower temperature “white light” needs a lot of blue added to it and very little red and as the temperature climbs up, the amount of added red grows while the added blue goes down.

## Color correction for white temperature

For the calibration purposes we have acquired a Philips “Hue White and Color Ambiance A19 LED Starter Kit” that allowed us to test various illumination scenarios for a range of color temperatures. For a given white color temperature setting we have dialed the red and blue gains to make the scene “white” (leaving the green gain at its constant value of $1024$).

Corrections to the red channel were way more noticeable than those to the blue one so we approximated the blue gains' graph with a single line, described by the formula $B = 4205.4 - T*0.4087$.

Red channel gains are approximated by two line segments, bordering the $3500°K$ mark:

$R = \begin{cases} 467.6 + T * 0.166 & \quad \text{if } T < 3500°K \\ 82 + T * 0.277 & \quad \text{if } T >= 3500°K \end{cases}$

### Experimental data and verification

Here is the table with the results of that testing and corresponding calculated values based on the above formulae:

 Manually set Calculated Color, K Red Blue 2000 800 3388 800 3388 2296 840 3285 849 3267 2592 913 3196 898 3146 2888 959 3078 948 3025 3184 1016 3005 997 2904 3480 1046 2858 1046 2783 3776 1119 2710 1128 2662 4072 1195 2519 1210 2541 4368 1296 2460 1292 2420 4664 1370 2298 1374 2299 4961 1458 2121 1456 2178 5257 1561 2033 1538 2057 5553 1620 1895 1620 1936 5849 1750 1782 1702 1815 6145 1738 1694 1784 1694 6500 1738 1694 1882 1549

## Practical example

What does all that mean in practice? Suppose you have set up your scene with “white” lamps that are marked as $4100°K$. Based on the above information you'd know that to get the best “natural” colors out of that scene means setting your red channel gain to $1217$ and blue gain to $2529$ while leaving the green gain at its default $1024$ value.