Activity 6: Enhancing Color Images

đź•‘13:00, 26 Aug 2019

For this activity, I will be using the raw image (Fig. 1a) I took during the FST Week Concert at the College of Fine Arts. I felt this would be a good image to work on since there is a significant and discernible color cast due to the lighting of the venue. The photo was taken with auto white balance (which didn’t do a really good job of white balancing).

Contrast Stretching

I imported the original image as uint8. However, when performing any manipulation, I converted it first to float64 before casting it back to uint8 for displaying and saving purposes. Upon examination, I realized it was futile to perform contrast stretching since the maximum value of each channel was already 1.0. Further reading brought me to an article [1], where we can discard a certain percentile from the low and high ends of the histogram and stretch the remaining bins to fill the full range, according to

where refers to the channel being manipulated. The high and low values refer to the -th percentile of histogram values that are set as the upper and lower thresholds, respectively. This is actually the algorithm used by GIMP’s auto white balance. We can see from the resulting image in Fig.  1b that the reddish color cast has generally been removed, and the guitarist’s skin tone looks much more realistic.

Gray World

This algorithm assumes that the average color of the image is gray. The pixel values are manipulated according to [2]

where is the overall average and is the channel average. The result of this manipulation is shown in Fig.  1c. Note that the image is at roughly the same exposure level as the original because we did not perform contrast stretching on this one, but the white balance is similar to that of contrast stretching.

White Patch

This method is similar to how the White Balance Eyedropper Tool in image processing programs such as Lightroom or Photoshop work. Fig.  2 shows the location where I extracted a patch that is supposed to be white (upper 12th fret marker on the guitar). The result is shown in Fig. 1d. We can see that the guitarist’s skin tone still looks realistic, and the background is now a warmer white as compared to the previous algorithms.

Original
(a) Original
Contrast-stretched (CS)
(b) Contrast-stretched (CS)
Gray world (GW)
(c) Gray world (GW)
White patch (WP)
(d) White patch (WP)
Original histogram
(e) Original histogram
CS histogram
(f) CS histogram
GW histogram
(g) GW histogram
WP histogram
(h) WP histogram

Figure 1: Image enhanced using different algorithms (top) and their respective histograms (bottom).

Extracted white patch location

Figure 2: Extracted white patch location. The size of the bounding box has been exaggerated for easy location. The object of interest is the fret marker on the upper portion of the box.

Auto White Balance Algorithm through Average Equalization and Threshold (AWBAAET)

To combine everything, [3] proposes a method that modifies the gray world and contrast-stretching algorithms and uses a weighted sum of them to perform automatic white balancing. The modified gray world algorithm is

and the modified contrast-stretching is

where and are the lower and upper thresholds, respectively, and and are the overall maximum and minimum pixel values, respectively. The image intensity values are scaled according to the thresholds and not the extrema as to avoid over-stretching. The weight is then calculated as

where , are calculated by converting the image to YCrCb and taking the averages of the C channels, and are the standard deviations of the RGB channels. The paper stated that was a constant taken to be 200 and was obtained experimentally, but do not elaborate on how exactly it was obtained. Essentially, is the weight of the heavy color cast. The final image is obtained by

where and are the images enhanced using the modified contrast stretching and gray world algorithms, respectively. The result is shown in Fig. 3c alongside the other algorithms for comparison. Because of the heavy red color cast in the original image, the CS portion of the algorithm is given a greater weight, so the final image looks more like the CS-corrected image.

CS
(a) CS
GW
(b) GW
AWBAAET
(c) AWBAAET
CS histogram
(d) CS histogram
GW histogram
(e) GW histogram
AWBAAET histogram
(f) AWBAAET histogram

Figure 3: Comparison of the different auto white balance algorithms.

References

  1. S. Wang, Y. Zhang, P. Deng, and F. Zhou, Fast automatic white balancing method by color histogram stretching, 4th International Congress on Signal and Image Processing, 979-983 (2011).

  2. M. N. Soriano, Enhancing color images (2019).
  3. S. C. Tai, Y. Y. Chang, and C. P. Yeh, Automatic White Balance algorithm through the average equalization and threshold, in [2012 8th International Conference on Information Science and Digital Content Technology (ICIDT2012), vol. 3, 571-576](http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6269338&isnumber=6269316, (2012).

Keywords

contrast stretching
white balance
gray world
white patch
awbaaet