Wednesday, September 22, 2010

Color Image Processing

     Ever wondered what does the white balance setting in your camera means? Aside from using it to add special effects on the image, it is used to get the correct color of objects on the images that is on different light conditions.  In this activity, the different white balancing settings of a camera will be explored.  Then, images with wrong white balance settings will be corrected using two algorithms: the white patch and the gray world algorithm.
     Figure 1 shows images of colored paper clips with a white background taken under different lighting conditions.  The available white balance settings on the camera used are automatic, daylight, fluorescent, and tungsten.  These settings refer to the lighting conditions on which it must be used.  For the images taken inside a room with a fluorescent lighting, daylight and tungsten settings are not the appropriate settings (although it is not obvious for the daylight setting).  For images taken under natural light, the incorrect settings are fluorescent and tungsten.  For those taken directly under the sun, the incorrect settings are also fluorescent and tungsten.     Notice that the white background on the images with incorrect settings is not white at all.  For daylight, it is slightly yellow, for fluorescent and tungsten it is bluish. 
Figure 1a.  Image taken inside a room with a fluorescent lighting.
Figure 1b.  Image taken under natural lighting.

Figure 1c. Image taken under the morning sun (10:30am).
Figure 1.  A set of paper clips taken on different lighting conditions and white balance camera settings.


     To make the white background appear white for the wrongly white balanced images, white patch and gray world algorithm will be used. The white patch algorithm divides the RGB values of the image with the RGB values of the known white object.  This white balances the image.  For the gray world algorithm, the assumption is that the average color of the world is gray.  The balancing constants are the average of the RGB values of the image.  The RGB values are divided by these constants to white balance the image.  To prevent image saturation, the maximum pixel value were cut-off to 1.
Figure 2a.  Daylight white balance setting.
Figure 2b.  Tungsten white balance camera setting.
Figure 2.  Images taken inside a room with tungsten lighting.
 
Figure 3a.  Fluorescent white balance setting.
Figure 3b.  Tungsten white balance setting.
Figure 3.  Images taken outside a room with natural lighting.
Figure 4a.  Fluorescent white balance setting.
 Figure 4.  Images taken directly under the sun.

     The results show even white balancing for the white patch algorithm, while for the gray world algorithm there are apparent shades.  There are also some regions in the gray world white balanced images where the white background is still not white.  To compare the two algorithms further, objects with the same hue were imaged using a wrong white balance setting.  For this case, red hue was chosen and the image was taken under natural light and using tungsten as the white balance setting.

Figure 5.  Comparison of the white patch and gray world algorithm.

      It can be seen that the use of white patch algorithm showed better white balancing of the image compared to the gray world algorithm.  This result is also consistent with the results for different lighting conditions and camera white balancing settings.
     I would like to thank Dennis Ivan Diaz and Ma'am Jing for the helpful discussions.  I would give myself a grade of 9/10.  Although the required outputs are presented, the image quality was not that good because only a camera phone was used in this activity.

No comments:

Post a Comment