Wednesday, August 27, 2008

Activity 15: Color Camera Processing

The task: to investigate colors from images taken with a digital camera and different white-balancing techniques/settings.

The following images were of different-colored nail polish on white paper under a fluorescent light, taken with a Sony Ericsson DSC-T10 digital camera with an Exposure Value of -1.
automatic white balance setting

"daylight" setting

"cloudy" setting

"fluorescent" setting

"incandescent" setting

"flash" setting

**As we can see, the "best" settings for the set-up are the automatic white balance and fluorescent settings,as it should be; these show the colors as they are perceived by my eyes (albeit darker because of the low EV setting). The daylight setting makes them look dull (to balance out the bright sunlight), while the cloudy setting appears to increase their saturation. The incandescent white balance setting is by far the worst, giving a bluish tinge to the colors, evidenced by the now-light-blue paper background; this is to cancel out the yellow-orange tinge incandescent light usually casts on everything. The flash setting has the same effect as that of the daylight setting, though it makes them even darker, this is because light from the camera's flash bulb would be more intense than the diffused sunlight outdoors.


Next we use two popularly used automatic white balancing algorithms to enhance the most "wrongly balanced" image, which is of course the image taken using the Incandescent Light setting.

using the following code:
im=imread('act15v.jpg');

//im2=imread('white.jpg');

//r=mean(im2(:,:,1));
//g=mean(im2(:,:,2));

//b=mean(im2(:,:,3));

//im(:,:,1)=im(:,:,1)/r;

//im(:,:,2)=im(:,:,2)/g;
//im(:,:,3)=im(:,:,3)/b;

rg=mean(im(:,:,1));

gg=mean(im(:,:,2));

bg=mean(im(:,:,3));

im(:,:,1)=im(:,:,1)/rg;
im(:,:,2)=im(:,:,2)/gg;

im(:,:,3)=im(:,:,3)/bg;

imshow(im);

...the first (commented out) part employs the Reference White Algorithm. Basically, it takes the RGB values of a white reference part of the image and saves them as the variables r,g,b then divides the RGB layers of the image by the corresponding saved reference value. We obtained the following image:
image enhanced with Reference White Algorithm
**It effectively white balances the image, reverting the colors to more or less their real-world hues and shades. A few problems seen in the image include a few artifacts like the little dots on the paper and the big red ring on the bottom part which shouldn't be there, and the disappearance of the light yellow patch(7th from the last).

...the second part of the code employs the Grey World Algorithm, it assumes that the average color of the world is grey. Basically, the code takes the averages of the RGB values of the unbalanced image then divides the RGB layers of the image by the corresponding stored averages. We obtained the following image:
image enhanced with Grey World Algorithm
**This algorithm whites out the white and balances most of the others like the previous algorithm, it also has about the same specks and red ring. It is a poor choice for enhancing an
image though because it totally erases 3 of the patches, the orange and two shades of yellow, and most of the yellowgreen patch.

Now to see the effectiveness of the same algorithms on a wrongly-balanced image with just one hue (and a patch of white for reference). Below is a picture of the hems of shirts with different shades of purple(/violet), taken with the same digital camera and under the same light as the previous set of pictures, again using the "incandescent" white balance setting. This is followed by the same image after it has been white balanced using the Reference White Algorithm, then again using the Grey World Algorithm.

"Shades of Purple" after Grey World Algorithm balancing
**Looking at the above pictures, the Reference White is obviously the better algorithm, in this particular set-up at least. The Reference White gives almost the real-world shades, although it whites out the shirt with the lightest shade of purple; while the Grey World not only whites out the two shirts with the lightest shades of purple, the colors are very off, making them bluish, greyish, even making the top left one look more brown than purple.


**I give myself a grade of 10 for this activity, because the results were satisfactory and all the objectives were achieved.

**thank you to mark leo for the help.

No comments: