Introduction [3]

This is the color balancing technique used in Adobe Photoshop's "auto levels" command. The idea is that in a well balanced photo, the brightest color should be white and the darkest black. Thus, we can remove the color cast from an image by scaling the histograms of each of the R, G, and B channels so that they span the complete 0-255 scale. In contrast to the other color balancing algorithms, this method does not separate the estimation and adaptation steps.

In order to deal with outliers, Simplest Color Balance saturates a certain percentage of the image's bright pixels to white and dark pixels to black. The saturation level is an adjustable parameter that affects the quality of the output. Values around 0.01 are typical.

Implementation: simplestColorBalance.m

function simplestColorBalance(filename,outFile,satLevel,plots) %simplestColorBalance(filename,outFile,satLevel,plot) % Performs color balancing via histogram normalization. % satLevel controls the percentage of pixels to clip to white and black. % Set plot = 0 or 1 to turn diagnostic plots on or off.
  1. Determine the histogram for each RGB channel and find the quantiles that correspond to our desired saturation level. q = [satLevel/2 1-satLevel/2]; tiles = quantile(imRGB_orig(ch,:),q);
  2. Cut off the outlying values by saturating a certain percentage of the pixels to black and white. %saturate at the appropriate pts. in distribution imRGB(ch,:) = cbsaturate(imRGB_orig(ch,:),tiles);
  3. Scale the saturated histogram to span the full 0-255 range. bottom = min(imRGB(ch,:)); top = max(imRGB(ch,:)); imRGB(ch,:) = (imRGB(ch,:)-bottom)*255/(top-bottom);

Results

ISET was used to generate an artifical color cast on the flower. Notice how the background is forced to white. This is characteristic of the algorithm.

The background shadows are lost as the algorithm saturates them to black.