Sunday, October 12, 2008

A15: Color Image Processing

In this activity, two popular algorithms will be used for white balancing. The Reference White Algorithm(RWA) and the Gray World Algorithm(GWA). For RWA, we will pick a color in an image as reference for white. Its RGB values will then be used to divide other RGB channels. For GWA, we take the average of each channel and take their averages as balancing constants. 

Using these algorithms, we compare the images after application to different white balance settings of the camera. 

Flourescent


Tungsten


Daylight


Blue objects


Comparing the images from both algorithms, the reference white is much better to use than the gray world algorithm in images where there are many colors. The same goes for images with just different hues.

CODE:

//Reference White

I = imread('image');

imshow(I);

pix = locate(1);

Rw = I(pix(1), pix(2), 1);

Gw = I(pix(1), pix(2), 2);

Bw = I(pix(1), pix(2), 3);


I(:, :, 1) = I(:, :, 1)/Rw;

I(:, :, 2) = I(:, :, 2)/Gw;

I(:, :, 3) = I(:, :, 3)/Bw;

I(I > 1.0) = 1.0;

imshow (I);


//Gray World

I = imread('image');

Rw = mean(I(:, :, 1));

Gw = mean(I(:, :, 2));

Bw = mean(I(:, :, 3));


I(:, :, 1) = I(:, :, 1)/Rw;

I(:, :, 2) = I(:, :, 2)/Gw;

I(:, :, 3) = I(:, :, 3)/Bw;

I = I * 0.5;

imshow(I);

No comments: