Thursday, August 6, 2009

Activity 11: Camera Processing

In this activity, we observed the effect of different white balancing options in cameras. Also, we applied the white patch and gray world algorithms on improperly white balanced images. Both RGB objects and objects with same color but different hues were used. It was found that for all images used, it is better to use the white patch algorithm.

For the first part, the same set of images were captured under different white balancing options in the camera. The white balancing options used were cloudy, daylight, fluorescent, fluorescentH, and tungsten. Capturing the images under these conditions is like illuminating the object with a light source with the same color temperature as the white balancing conditions. The images are shown below. The image captured under automatic white balancing is also included for comparison. Note that in the images the order is as follows
automatic white balanced
cloudy daylight fluorescent
fluorescentH tungsten
RGB

GREEN

From the images it can be observed that image taken under the tungsten condition is obviously improperly white balanced. The supposedly white paper appeared blue.

The white patch and gray world algorithms is then applied to these images to for white balancing. Each image has RGB values. In the white patch algorithm, we get a patch from the image that is supposedly white. The RGB value of this patch is used to divide the RGB value of the whole image such that Rn = R/Rw, Gn=G/Gw and Bn=B/Bw where Rn,Gn, Bn are the white balanced RGB values, R,G,B are the original RGB values and Rw,Gw,Bw are the RGB values of the patch.

For the gray world algorithm, it is assumed that the average color is gray. The key term here is "average". To operate the gray world algoirthm, we used average of the R,G, and B values and used this to divide the RGB values of the original image.

The following images are the result of the white patch and gray world algorithms on the images.

RGB IMAGES
Cloudy
Daylight
Fluorescent
FluorescentH
Tungsten

Notice that better images result from the white patch algorithm. The gray world algorithm produces a very bright image. This is maybe because white dominates in the image where it was applied.

GREEN IMAGES

Cloudy
Daylight
Fluorescent
FluorescentH
Tungsten

Like in the RGB images, the white patch algorithm obviously works better. Again, brighter images are observed in the gray world algorithm. Notice though that yellow green notebook became yellow when both algorithms were applied. This may be because the yellow color of the notebook is stronger than that of its green color.

The code:
stacksize(4e7)
rgbwp=imread("F:\186-11\wp.jpg");
rgb=imread("F:\186-11\green\tungsten.jpg");

rw=rgbwp(:,:,1);
gw=rgbwp(:,:,2);
bw=rgbwp(:,:,3);

r=rgb(:,:,1);
g=rgb(:,:,2);
b=rgb(:,:,3);

//white world
Rw = sum(rw)/(size(rgbwp,1)*size(rgbwp,2));
Gw = sum(gw)/(size(rgbwp,1)*size(rgbwp,2));
Bw = sum(bw)/(size(rgbwp,1)*size(rgbwp,2));


//gray world
Rg = mean(r);
Gg = mean(g);
Bg = mean(b);


rr=r/Rw;
rg=g/Gw;
rb=b/Bw;

gr=r/Rg;
gg=g/Gg;
gb=b/Bg;

chuva = [];
chuva(:,:,1)=rr;
chuva(:,:,2)=rg;
chuva(:,:,3)=rb;
chuva(chuva>1) = 1;
//scf(0), imshow(chuva);
//scf(1), imshow(rgb);

chuva2 = [];
chuva2(:,:,1)=gr;
chuva2(:,:,2)=gg;
chuva2(:,:,3)=gb;
chuva2(chuva2>1) = 1; //pin values to 1
//scf(1), imshow(chuva2);

imwrite(chuva,"F:\186-11\result\green\tungstenw.jpg");
imwrite(chuva2,"F:\186-11\result\green\tungsteng.jpg");

Notice that the image values are all pinned to 1.

For this activity, I give myself a 10/10 since I believe I was able to perform the task asked for this activity. Thank you to Neil and Earl for the discussion we had.

1 comment:

  1. Some parts are already saturating, these are mostly seen in the gray world algorithm results. The trick is to multiply the image by a number less than 1.0. Yellow is produced by red and green together.

    ReplyDelete