This application claims priority under 35 U.S.C. §119(a) to a Korean Patent Application filed in the Korean Intellectual Property Office on Feb. 20, 2009 and assigned Serial No. 10-2009-0014438, the entire disclosure of which is incorporated herein by reference.
1. Field of the Invention
The present invention relates generally to an apparatus and a method for processing a digital image, and more particularly, to an apparatus and a method for adjusting white balance of a digital image.
2. Description of the Related Art
An image device may perform white balance adjustment on images that it reproduces or photographs. The white balance adjustment affects the color of the image so that it is equal or similar to a color that a user has perceived.
A difference in color between the image and the user's perception can be caused by a light source illuminating a subject of the image or by an external background where the subject is photographed. Examples of the light source include, for example, sunlight, a fluorescent lamp, and incandescent lamp, etc. A user may not be aware of a variation in color despite a change in illumination or background, because the user adapts to these changes. However, since devices, such as digital cameras, are not capable of such an adaptation, a color perceived by the user, may be different from a color of an image.
Through white balance adjustment, an image having a color that is different from that perceived by the user is adjusted such that the color of the adjusted image is equal or similar to that perceived by the user. White balance adjustment is based on a white region of the image, and restores the white color, which was changed by the light source or the surrounding background, to the white color the user perceived.
White balance adjustment may be performed by two different methods. A first method estimates a type of background illumination used while photographing a subject and adjusts the white balance according to the estimation. This method searches for a white region(s) of an image. A gain of each channel is adjusted based on an average of image information or RGB values corresponding thereto, or an average of color difference signals (R-Y) and (B-Y). A second method, which does not estimate the type of illumination, adjusts a gain of each channel based on an average for each channel of the entire image. A color composed of an average for each channel is assumed to be white when an input image has a sufficient color variation. Specifically, it is possible to achieve white balance of an image by adjusting gains of RGB values of an image so that an average for each channel becomes equal.
In the first method of adjusting white balance by estimating a type of background illumination, searching for a white region of an image should precede all other steps. Therefore, this method is only able to adjust white balance when an input image includes a white region. If the white region of the image is not detected, white balance adjustment performance deteriorates.
Additionally, since the first method does not consider a characteristic of a sensor while photographing a subject, its performance after white balance adjustment is not high. Further, since this method uses one transformation matrix, or lookup table, during color matching after white balance adjustment regardless of the light source, the color may be viewed differently according to the light source.
The present invention has been made to address at least the above problems and/or disadvantages and to provide at least the advantages described below. Accordingly, an aspect of the present invention provides a white balance adjustment apparatus and method for minimizing color distortion caused by light sources in an image with a white color.
According to one aspect of the present invention, a method for adjusting white balance of a digital image is provided. An input image is converted into a YCbCr color space. White pixels of the converted input image are detected by determining whether each pixel of the converted input image is included in a preset region of the YCbCr color space. A gain of each channel is calculated from averages of R, G and B values of the detected white pixels. White balance adjustment is performed by applying the calculated gain of each channel to each pixel of the input image.
According to another aspect of the present invention, an apparatus for adjusting white balance of a digital image is provided. The apparatus includes an image converter for converting an input image into a YCbCr color space. The apparatus also includes a white detector for detecting white pixels of the converted input image by determining whether each pixel of the converted input image is included in a preset region of the YCbCr color space. The apparatus further includes a gain calculator for calculating a gain of each channel from averages of R, G and B values of the detected white pixels. The apparatus additionally includes a white balance executer for performing white balance adjustment by applying the calculated gain of each channel to each pixel of the input image.
The above and other aspects, features and advantages of the present invention will be more apparent from the following detailed description when taken in conjunction with the accompanying drawings, in which:
Embodiments of the present invention are described in detail with reference to the accompanying drawings. The same or similar components may be designated by the same or similar reference numerals although they are illustrated in different drawings. Detailed descriptions of constructions or processes known in the art may be omitted to avoid obscuring the subject matter of the present invention.
The embodiments of the present invention adjust white balance of a digital image to minimize color distortion that is caused by light sources and to improve image quality. The embodiments of the present invention convert an input image into a YCbCr color space. A linear function graph is modeled to indicate a relation between chrominance |Cb|+|Cr| and luminance Y of an image obtained by photographing 6 patches at the bottom of 24 patches of a Macbeth color checker for each light source. White pixels of the input image are detected using the modeled linear function graph. Further, embodiments of the present invention calculate R, G and B gains from R, G and B averages of the detected white pixels, adjust white balance using the calculated R, G and B gains, distinguish a light source based on a gain of a particular channel, and apply a color matching matrix corresponding to the distinguished light source. A white balance adjustment apparatus and method according to an embodiment of the present invention are described in detail with reference to accompanying drawings.
Referring initially to
The image converter 110 converts an input image into a form of a YCbCr color space using Red (R), Green (G) and Blue (B) values of each pixel of the input image. Equation (1) is used for the RGB-to-YCbCr conversion.
Y=0.2990×R+0.5870×G+0.1140×B
Cb=−0.1687×R−0.3313×G+0.5000×B
Cr=0.5000×R−0.4187×G−0.0813×B (1)
R, G and B represent R, G and B pixel values of a particular pixel, Y represents a luminance component, and Cb and Cr represent color difference components.
The white detector 120 detects white pixels based on image information that is converted into the YCbCr color space by the image converter 110.
The white detector 120 models a linear function graph of chrominance |Cb|+|Cr| versus luminance Y for each of 6 gray patches at the bottom of 24 patches of a Macbeth color checker. The Macbeth color checker is a test chart that is shown by reference numeral 800 in
The further a curve is from the gray axis (Cb=Cr=0), the greater the luminance. Thus, the luminance increases with |Cb|+|Cr|.
The graph of
The pixels are determined to be white pixels even when their luminance is greater than an average luminance of the input image by a preset multiple c. Such white detection is performed by Equation (2) and Equation (3).
(a−tol)(|Cb|+|Cr|)+b<Y<(a+tol)(|Cb|+|Cr|)+b (2)
‘a’ represents a slope of a modeled linear function graph indicating a Y-|Cb|+|Cr| relation of a particular light source, ‘b’ represents a y-intercept, tol represents a preset slope range, and Y represents luminance of an input image.
c
Equation (2) is applied to both linear function graphs calculated for the five light sources. That is, pixels satisfying all of formulae derived from the five light sources are determined and detected as white pixels.
If R, G and B values of an input image are close to gray, i.e., if Cb and Cr of the input image are simultaneously close to zero (0), they are excluded during white detection. Thus, if absolute values of Cb and Cr of the input image are less than a preset threshold, they are excluded during white detection.
R, G and B gains that are to be used in automatic white balance adjustment are calculated with the detected white pixels. If gray pixels are included during the calculation, the image may be colored as a result of the automatic white balance. Therefore, when Equation (4) is satisfied in addition to Equation (2) or Equation (3), the pixels are determined to be white pixels.
Cb<TH or Cb>TH
Cr<TH or Cr>TH (4)
Th represents a preset threshold that is a criterion for detecting gray.
Referring again to
The white balance executer 140 performs white balance adjustment using the R, G and B gains calculated by Equation (4). The white balance adjustment is performed by applying Equation (6) to all pixels of the input image.
R′=R×R
gain
G′=G×G
gain
B′=B×B
gain (6)
R′, G′ and B′ are pixel values that underwent white balance adjustment.
The color matching executer 150 applies a color matching matrix to the image that underwent white balance adjustment.
After the white balance executer 140 performs white balance, the color matching executer 150 applies a matrix for color matching the white balance results.
Referring now to
To calculate a color matching matrix, the white balance adjustment apparatus performs white balance adjustment in step 810 after photographing a Macbeth color checker 800 at five light sources of Horizon, A, U30, Cool white, and D65. R, G and B values of each patch are acquired in step 820.
The white balance adjustment apparatus measures a Lab of 24 patches in step 840. The “Lab” represents a value of a Lab color space, which is a standard of a color space and is represented in color coordinates or stereographic coordinates of L*, a*, b*. L* indicates lightness, a* represents a level of Red and Green, and b* represents a level of Yellow and Blue.
The white balance adjustment apparatus expresses the measured Lab in the RGB form in step 830, and converts R, G and B into R′, G′, and B′ in step 850. A matrix that undergoes linear transformation from R, G and B of each patch acquired after execution of white balance to R′, G′, and B′ converted from the Lab, becomes a color matching matrix in step 860. Because every light source has a different color, the white balance adjustment apparatus independently calculates a color matching matrix for each light source, and may perform regression analysis to calculate the color matching matrix.
Referring to
In step 940, R, G and B gains are calculated from the R, G and B averages of the white pixels detected in step 930. In step 950, white balance adjustment is performed using the R, G and B gains calculated in step 940. In step 960, light sources are distinguished using the R gain and/or B gain of the image, and color matching is performed by applying a color matching matrix corresponding to the light source. The color matching matrix for each light source is calculated in accordance with the process described in
As is apparent from the foregoing description, the embodiments of the present invention perform white balance adjustment in accordance with the process described above, thereby minimizing color distortion caused by the light sources and thus improving image quality.
Also, the embodiments of the present invention can improve performance of white balance adjustment by detecting white regions of an image, thereby making it possible to minimize color distortion caused by light sources and improve the image quality.
While the invention has been shown and described with reference to certain embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
10-2009-0014438 | Feb 2009 | KR | national |