4: White Balancing

White Balancing is a method to color correct images with an overlaying tint, by making known white areas in the image appear white. There are 3 methods to achieve this:

Snowy Mountains

We will study this snowy mountains picture. A blue tint is common on images with snow. This is usually because the camera lens normalizes the colors available in the entire image and the blue sky and shadows cause this blue tint. Since we know that snow is white, white balancing can be used to solve this.

1. White Patch Algorithm
Since we know that 255 or the maximum of a single channel makes white, the white patch algorithm works by normalizing each channel of the image, individually. This scaling forces the channels to have the max 255 value and is supposed to make the image whiter.

Max white patch

The difference in the image is hardly visible and most of the snow is still blue.

Max values in original image

The white patch algorithm did not work because the max 255 value is already present in the original image. The algorithm would only have worked if these values were lower than 255. To look at why this is happening, the distribution of channel values is needed.

Channel Value Distributions

It can be seen that there are a lot of trailing channel values after the peak. The mere presence of even a few values of 255 prevents the white patch algorithm to work. The vertical lines show (95th) percentile values per channel. This percentile value can be experimented with to find the channel value to set as the cutoff. The white patch algorithm would work after this to normalize the values.


The different percentile values show how the image is whitened, visibly in the snow appearing in the front most mountain. A value between the 70th and 90th percentile may be suitable, although the mountains at the back still have blue tint.

2. Gray World Algorithm

Gray World Algorithm

The gray world algorithm assumes that on average, pixels are gray and that each the overlapping channels make up this gray. With this, it adjusts each channel to have the same mean value. Visibly, a red tint is now present. Again, this algorithm did not work as well as needed.

3. Ground-Truth Algorithm

Ground-Truth Algorithm

The algorithm relies on setting a certain area as the ground truth, which we know is surely white. Applying that to the image allows for quite a realistic white balancing.


If a known dark area is used as the white patch, the image is whitened too much.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nisarg Nigam

Nisarg Nigam

MS Data Science student at Asian Institute of Management