Lab 5- Midterm Project- CSE 467, due Mon. Nov. 10


White Balance as a part of Bayer Interpolation

After demosaicing, the next step in processing the raw pixel data is to perform a white balance operation. A white object will have equal values of reflectivity for each primary color: ie:

R = G = B

A. An image of a white object can be captured and its histogram analyzed. The color channel that has the highest level is set as the target mean and the remaining two channels are increased with a gain multiplier to match. For example, if Green channel has the highest mean, gain ‘a’ is applied to Red and gain ‘b’ is applied to Blue.

G’ = R’a = bB’

B. The White Balance will vary, based on the color lighting source (Sunlight, Fluorescent, Tungsten) applied to the object and the amount of each color component within it. A full color natural scene can also be processed in the same fashion. This “Gray World” method assumes that the world is gray and the distribution of primaries color will be equal.

White Balance

C. The “White Patch” method attempts to locate the objects that are truly white, within the scene; by assuming the whites pixels are also the brightest (I = R+G+B). Then, only the top percentage intensity pixels are included in the calculation of means, while excluding any pixels that may have any channel that is saturated.

What you should do:

  1. We are going to implement version A above. Start with one of your interpolation implementations from Lab 4. Use an unused switch (maybe SW4) for white balance selection.
  2. When SW4 is on (up), a Red target cross hair pattern is shown on the output screen. The user should position the camera to show a white object in the target area. Think about where to add the code to accomplish this; the target marker should show on both the VGA and the LCD.
  3. When the switch is switched off (negedge SW4), the gain values should be calculated for the nine or sixteen pixels surrounding the cross hair.
  4. When the switch is in the off state, the color outputs of your demosaic algorithm should be scaled by the gain values. You should see a shift similar to the illustration, to correct for the lousy flourescent lighting in the lab.

Answer the following questions:

  1. Describe your implementation of the calculations involved, paying attention to the number of bits in the operands, and the position of your decimal points.
  2. What is the accuracy of your implementation?
  3. What is the cost of this algorithm in time and resources?

Extra credit (choose one):

  1. Contrast stretching makes sure the input sample with the lowest value is mapped to black (0); and that the one with the highest to 1.0 (full scale). The values are recalculated by using linear interpolation.Contrast stretching automatically counters under and over exposure, as well as the ability to extend the used luminance range. Implement contrast stretching controlled by another switch. How does contrast stretching interact with your manual exposure control?

  2. Controlled by a switch, implement an exposure controller that increases or decreases the exposure time to optimise the green maxval to the closest value to full scale, but not clipped. You'll need to build a state machine to control this. Why green?

Your completed project should be emailed to me (bruceh@cs) AND to Ryan by Monday, Nov. 10, 2008, by class time.

These may be of help:


Comments to: cse467-webmaster@cs.washington.edu