Home > Image Processing > 12. Color camera processing

12. Color camera processing

A digital image is made of red, green and blue components overlaid at different levels. Each pixel is defined by a summation of the product of the spectral power distribution of the incident light source S(λ), the surface reflectance ρ(λ) and the spectral sensitivity of the camera η(λ).  If a camera has spectral sensitivity η(λ), η(λ), η(λ) for its RGB channels, the color of the pixel is defined as:

whereis the balancing constant that is equal to the inverse of the camera output for a white object ρ(λ).  The equations tell us why some pictures captured by cameras do not appear satisfactory.

White Balancing

Digital cameras have settings called WHITE BALANCE or BW, which allows us to select appropriate constants for specific conditions when capturing images.  Illumination conditions would depend whether it is sunny, cloudy or under the light of a bulbs.  Some cameras include an AWB or Automatic White Balance.  Learning how to set these in the camera allows obtaining an image wherein the white color is properly represented in the image and the other colors are also rendered properly.

Automatic White Balancing Algorithms

There are two popularly known algorithms for automatic white balancing.  The equations for RGB tell us the raw output of the camera divided by the camera output for a white object.  The White Patch Algorithm uses a white object and utilizes its RGB values as divider. The Gray World Algorithm, on the other hand, assumes that the average color of the world is gray.  It obtains balancing constants by taking the average RGB values of the image.

For instance we assemble a group of colored objects (with major hues represented) with a white background.  We choose a specific light source (here, fluorescent lamp) to capture them on image.

We locate a pixel belonging to a white object and with it set the hue values for white (Rw, Gw, Bw).

im = imread('A1. daylight.png');

R = im(:, :, 1);
G = im(:, :, 2);
B = im(:, :, 3);

//white object at (108, 213)
R_white = R(108, 213);
G_white = G(108, 213);
B_white = B(108, 213);

We implement the White Patch Algorithm by dividing all the RGB values of the pixels with their respective white balancing constants.

R_balanced = R / R_white;
G_balanced = G / G_white;
B_balanced = B / B_white;

To make sure that there are no pixels exceeding 1.0, we apply clipping on them to 1.0.

R_balanced(find(R_balanced > 1)) = 1;
G_balanced(find(G_balanced > 1)) = 1;
B_balanced(find(B_balanced > 1)) = 1;

im(:, :, 1) = R_balanced;
im(:, :, 2) = G_balanced;
im(:, :, 3) = B_balanced;

Same process will be performed for Gray World Algorithm, except that the white balancing constants for RGB should be the average value for the RGB planes.

R_white = mean(R);
G_white = mean(G);
B_white = mean(B);

The resulting images from these algorithms are shown in Figure 1 below.

White Balance White Patch Gray World
D
A
Y
L
I
G
H
T
S
H
A
D
E
T
U
N
G
S
T
E
N
F
L
U
O
R
E
S
Figure 1. Captured images at different white balance camera settings and resulting images after applying the White Patch and Gray World aAlgorithms.

From the images above, we can see that raw images captured at daylight and shade settings produce good approximations of the actual fluorescent setup.  However, the daylight image has little influences of blue, as well as tungsten which almost saturates the entire picture. The images corrected show fair results after applying the two algorithms.  The White Patch algorithm produced a good correction of the color values in a moderate way.  The output from the Gray World algorithm, however, put in too much brightness on the image, which we can suppose have resulted from several clipped pixels along the image.

We repeat these steps but now apply them to objects with similar hues and only put a small white object as reference.  Figure 2 shows the results after applying the two algorithms.

White Balance White Patch Gray World
D
A
Y
L
I
G
H
T
S
H
A
D
E
T
U
N
G
S
T
E
N
F
L
U
O
R
E
S
Figure 2. Captured images (of objects with similar hue) at different white balance camera settings and resulting images after applying the White Patch and Gray World Algorithms.

From the images above we can see the difference in accuracies of the resulting images upon performing the white balancing algorithms when the image is not dominated by white colors.  We can see that the images processed with the Gray World algorithm was altered significantly due to the lack of white background.  The White Patch algorithm, however, maintains good rendering of the colors and maintains a good representation of the objects.

From these outputs, the more favorable method to use (and recommend) is the White Patch algorithm for the reason that it is more accurate in representation and more safe for pictures under various settings.

For this segment, I would rate myself 10 for being able to capture and process the images as prescribed by the algorithms.

Credits: Dennis D., Alex C., and Tin C. (for lending me her camera).

———————————————————————————————–—————–————————————
References:
[1] Soriano, 2010. Color camera processing. Applied Physics 186.
[2] The Scilab Reference Manual. 2010.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: