White Balance

Photography Fundamentals

Course 1 · Chapter 7 · White Balance: Getting Colour Right

The Problem

Photography Fundamentals 4 showed that light sources differ widely in colour temperature, from about 1,850 K for a candle to 6,500 K for an overcast sky. Our eyes and brain largely adjust to this; a camera does not. White balance is how the picture is corrected so that neutral colours, such as a white wall, look neutral.

Wikipedia's Color balance article describes colour balance as the global adjustment of colour intensities (typically red, green and blue) so that neutral colours render correctly, with white balance the most common kind. It makes a white object look white rather than tinted. The article gives three reasons it is needed: camera sensors do not respond like the human eye, display properties must be accounted for, and shooting conditions often differ from viewing conditions.

Camera Settings

The article says cameras may offer manual lighting selection, automatic white balance or custom white balance. Its only worked example of presets is one camera model, the Nikon Z 50:

LightApproximate setting (Nikon Z 50, per the article)
Incandescentabout 3,000 K
Direct sunlightabout 5,200 K
Flashabout 5,400 K
Cloudyabout 6,000 K
Shadeabout 8,000 K

Users can also set any value from 2,500 to 10,000 K on that camera. Other makers' presets and values differ, and I did not check them (check). Notice that these are close to Chapter 4's values but not the same: 3,000 K for incandescent against 2,400 K for a standard lamp, and 6,000 K for cloudy against 6,500 K for overcast. A preset is a nominal setting, not a measurement.

Custom white balance
The article says that on some cameras you can point the camera at a gray card or other neutral object and press a button to capture the ambient light, so the camera sets the correct balance.

Automatic White Balance and the Gray World Idea

The article says the algorithms behind automatic white balance perform generalised chromatic adaptation but does not describe them in detail; it mentions estimation approaches such as Retinex, neural networks and Bayesian methods. It does not discuss the "gray world" assumption (and the Wikipedia page I tried for it returned an error), so the following is my own illustration of a well-known simple idea, not the method any camera uses (check).

The gray world idea assumes that the average colour of a whole scene is neutral grey. If the red average is too high, scale red down, and scale blue up if it is too low. The script below does that and I ran it, with a made-up scene lit by warm light.

def gray_world(pixels): """Scale R, G, B so their averages match the overall average.""" n = len(pixels) avg = [sum(p[i] for p in pixels) / n for i in range(3)] grey = sum(avg) / 3 gains = [grey / a for a in avg] fixed = [tuple(min(255, round(p[i] * gains[i])) for i in range(3)) for p in pixels] return gains, fixed # A scene lit by warm light: everything leans red. scene = [(200, 150, 100), (160, 120, 80), (240, 180, 120), (100, 75, 50)] gains, fixed = gray_world(scene) print("gains (R, G, B):", [round(g, 2) for g in gains]) for before, after in zip(scene, fixed): print(before, "->", after)
# Output gains (R, G, B): [0.75, 1.0, 1.5] (200, 150, 100) -> (150, 150, 150) (160, 120, 80) -> (120, 120, 120) (240, 180, 120) -> (180, 180, 180) (100, 75, 50) -> (75, 75, 75)
Too good to be true
Every pixel came out a perfect grey. That is because I made the scene by tinting greys with a fixed warm cast, so the assumption holds exactly. Real scenes are not like this, and Exercise 1 shows what happens when the assumption is wrong. Also, real cameras work on linear sensor data and more carefully, so do not treat this as how a photo app works (check).

Raw Files

The article says getting the balance right at capture is advantageous. If balancing has to happen later, adjusting the raw image data tends to distort chromatic colours less than adjusting in monitor RGB. What a raw file is gets its own treatment in Photography Fundamentals 8.

Not Yet Verified, and Sources

  • Sources. Wikipedia article Color balance, read through a page summary. The Gray world page I tried returned an error and was not read.
  • Not on the page read. The gray world assumption and my script (my own illustration), other makers' presets, and mired shifts (check).
  • Not tested. I did not test the script on a real image.

Exercises

Exercise 1

Run the script on a scene with a large strongly red object: [(200, 40, 40), (100, 100, 100), (120, 120, 120), (80, 80, 80)]. What happens to the three grey pixels, and what does that tell you about the gray world assumption?

Exercise 2

Using the table, which preset would you try for (a) a living room under an ordinary lamp, (b) a sunny afternoon, (c) a photo of a shaded garden path on a bright day? If the result looks too blue or too orange, which way would you move the kelvin setting, and why?

Exercise 3

Run the script on a cool-cast scene: [(90, 120, 200), (60, 80, 140)]. Give the gains, say which colour is boosted and which reduced, and explain what light source might have caused such a cast.

Quick Reference

  • White balance: adjusting colour so neutrals look neutral
  • Camera options: manual selection, automatic, custom (grey card)
  • Example presets (one model): 3,000 / 5,200 / 5,400 / 6,000 / 8,000 K
  • Gray world: my illustration only; fails with large coloured areas
  • Check: other makers' presets, real algorithms
Coming next
Photography Fundamentals 8 covers raw files, JPEG and basic editing.