A kind of self-adapted white balance correction method
Technical field
The present invention relates to a kind of self-adapted white balance correction method that is used for digital camera and Digital Video and relevant imaging device.
Background technology
People's vision system is identical to identical color perception under different light substantially.When white object moves to the many incandescences of ruddiness composition from the many daylight of blue light ingredient, people's vision system can adjust automatically, comes the component of balance red, green, blue, to guarantee that white object all presents white under any illumination condition.The technology of this balance red, green, blue is called the white balance technology.Various imaging devices are exactly to adopt the Automatic white balance algorithm to come anthropomorphic dummy's vision system, thereby make white object can both present real white in image under different illumination conditions.
In existing technology, a kind of auto white balance method is that the supposition entire image all needs to carry out white balance statistics and processing.With Fig. 1 is example, and this method will be added up the mean value of RGB component of all pixels of entire image
With
Then the output gain of three Color Channels is respectively:
Ggain=1.0 (2)
Adopt this method to calculate channel gain, the high saturation color component also can be added up into usually, the consequence that causes like this is that the object when the high saturation color enters or when leaving a certain scene, its influence can make the rgb value deflection.The effect of high saturation color in the RGB mean value calculation can finally cause the object color distortion.For example, when red object enters the scene of red background, can directly have influence on the distortion of object color by the channel gain of top formula calculating.
Disclosed another Automatic white balance technology then is the image pixel value of statistics white portion, may further comprise the steps:
(1) earlier original image data is become the real image of a width of cloth through interpolation processing, promptly each pixel comprises three components of RGB;
(2) the traversal entire image judges whether current pixel point is the white pixel point.Green/red the ratio (G/R) of calculating pixel point and green/blue ratio (G/B).If these two ratios all are in given scope, determine that then this pixel is selected pixel.
(3) add up all selected pixels, calculate the mean value of RGB component.
(4) by formula (2) calculate the gain of RGB passage.
Though said method can reduce the influence of high saturation pixel to object color effectively, the low saturation pixel is existed certain limitation to the influence of object color.Be applied on the calculating channel gain when the low saturation color component is taken as gray component, also can have influence on the true colors of object.Its corresponding colour temperature of Different Light is also inequality, therefore it is trickle inconsistent to cause the intensity of rgb color composition also to have under different illumination conditions, when when a kind of surround lighting is transformed into another kind of surround lighting, said method can not effectivelyly carry out adaptive judgement and processing.And when not having tangible white portion on the image, this method will not possess the ability of analyzing the present image light source, and this will cause the error of white balance correction to produce.And this method is that the RGB component of each pixel of entire image is handled, and has increased amount of calculation.
Summary of the invention
The objective of the invention is to provide a kind of and can eliminate high saturation and low saturation influence of color, self-adapted white balance correction method fast at raw image data.
The invention provides a kind of self-adapted white balance correction method, its step is as follows:
(1) raw image data is carried out piecemeal, a piece is used as an original pixels;
(2) calculate R component in each piece, the mean value of G component and B component, then the mean value of Ji Suaning is the R of original pixels, G, B color value; Obtain the G/R ratio and the G/B ratio of each data block, and corresponding Grb value,
(3) judge G/R ratio and G/B ratio, whether the Grb value is in the chrominance space scope of restriction, determines that handled data are for needing selected gray pixels data;
(4) selected R, G, B data in the statistic procedure (3), and obtain the mean value of R, G, B data;
(5) according to mean value acquisition R, the G of R, G, B, gain Rgain, Ggain and the Bgain of three Color Channels of B;
(6), R, G, the B component of each pixel in the image carried out gain controlling with in the gain application that the draws view data after the interpolation.
Raw image data of the present invention carries out continuously not overlapping piecemeal, wherein comprises a green component in each piece at least, a blue component and an amount of red.
The space span of G/R, G/B and Grb then is the interval range of [0.5,2] among the present invention.
Gain control process of the present invention be the gain that will draw respectively with proofread and correct before corresponding the multiplying each other of data, obtain corresponding value of carrying out behind the white balance correction.
The present invention is for real-time system, and the gain of the R of current calculating, G, three Color Channels of B will be applied in the next frame data; And for the non real-time system, then be applied in the current images data.
Compared with prior art, the present invention has the following advantages:
(1) at first by judging the value of view data, adopts gray pixels to carry out light source and judge, determine the information of light source.Color of pixel scope for the n position is 0~2
n-1, the value of the segment limit [Lmin, Lmax] in the middle of only getting in the method, on duty during less than Lmin, think low saturation pixel or noise spot.And during greater than Lmax, color approaches pure white, and the difference of three components of RGB is also little, being used for calculating white balance has little significance, and for [Lmin, Lmax] the interior color value of scope, then can better determine current light emitting source, also just determined the gain of the RGB passage that the image white balance correction is required simultaneously; Eliminated any influence of high saturation color and low saturation color to white balance correction.
(2) initial data is directly carried out the branch block analysis, and the analysis result that adopts present frame acts on the method for back one frame, owing to be the transmission mode of data flow, can not preserve the intermediate object program of entire image data in the whole system, adopt this method not only can save system resource, can also improve the processing speed of whole system.
Description of drawings
Fig. 1 is the Array Model schematic diagram of raw image data;
Fig. 2 is the FB(flow block) of the inventive method;
Fig. 3 is for to be undertaken the not overlapping schematic diagram that is divided into 4 to Fig. 1 by 2 * 2 sizes;
Fig. 4, Fig. 5 are the diagrams of definition grey chrominance space;
Fig. 6 is image acquisition of the present invention and processing unit theory diagram.
Embodiment
Fig. 1 is the Array Model of the raw image data that collects of imageing sensor, and the present invention is primarily aimed at that raw image data handles.
Fig. 2 is the flow chart that the present invention is used to calculate the white balance correction gain.At first view data is carried out piecemeal, in real-time mode of operation, can not preserve the entire image data, therefore, can carry out real-time piecemeal the image data stream that imageing sensor collects; So also help improving the real-time of whole system.
The initial data (Raw Data) that imageing sensor collects is carried out not overlapping piecemeal by 2 * 2 sizes, for example Fig. 1 can be divided into 4, as Fig. 2:
A piece is used as a pixel, is example with first piece, and then its rgb value is respectively:
R=R11
G=(G12+G21)/2
B=B22
Auto white balance method relies on this rgb value to judge whether this pixel is gray pixels.The rgb value of gray pixels is used to calculate the gain of R, G, three passages of B, thereby realizes the function of image white balance.
Automatic white balance is calculated the G/R ratio and the G/B ratio of above-mentioned pixel, and the mean value (Grb) of G/R ratio and G/B ratio.If R, G, B, G/R, G/B and Grb are positioned at the chrominance space scope of appointment, can determine that then this pixel is a gray pixels.
For the view data among Fig. 1, each data can have 8, and 10,16 or the like, the sampling resolution of the imageing sensor correspondence of different model also can be different.For 10 initial data, when above-mentioned each value is in following scope, promptly during the cubic space among Fig. 4, Fig. 5, then this pixel is a gray pixels.
Grb∈[0.461,1.559] (3)
R∈[96,800]
G∈[96,800]
B∈[96,800]
For example when R=300, G=400, B=350, G/R=400/300=1.333, G/B=400/350=1.1428, Grb=(G/R+G/B)/2=(1.333+1.1428)/2=1.2379, these values have all fallen in the corresponding space span [0.5,2].Therefore this pixel is a gray pixels.
In the method also can be according to the actual light source situation, the span in the adjustment type (3) makes image reach better white balance effect.For example under red light source, image can be red partially, then can reach the white balance effect by the ratio standard that reduces G/R.
When the gray pixels of Automatic white balance recognition image, the rgb value of this pixel will be added up, a frame analyzed intact after, calculate the mean value of the RGB that adds up.
In order to improve treatment effeciency, imageing sensor continuous acquisition image, the RGB channel gain calculates in Automatic white balance mechanism after the initial data of whenever obtaining a two field picture, but this gain will act on next frame.
Fig. 6 is image acquisition of the present invention and processing unit theory diagram.After device started operation, the imageing sensor continuous acquisition was to view data, and the Automatic white balance processing module is carried out analyzing and processing to the current images data, calculates three required gains of passage of RGB.Initial data is through after the interpolation processing, and the RGB gain is applied in the white balance processing, and the pixel after the interpolation is carried out white balance correction.
Process is as follows:
Rnew=Rold×Rgain
Gnew=Gold×Ggain
Bnew=Bold×Bgain
Data before wherein Rold, Gold, Bold represent respectively to proofread and correct, and Rnew, Gnew, Bnew are corresponding value of carrying out behind the white balance correction.
In handling in real time, this gain will be applied to the next frame image, and in non real-time was handled, this gain then was applied directly to current data.Interpolation processing mainly is that the raw image data (see figure 1) is processed into the image that each pixel all comprises the RGB component by linear interpolation, cubic interpolation scheduling algorithm.Among the present invention the white balance gains that calculates is applied directly on the data after the interpolation processing, thereby realizes the function of image white balance.
Different light emitting sources, because its colour temperature difference, the RGB component in the image is also inequality, for example under incandescent lamp, the red component of image is higher than other component, and under daylight, blue component will be higher than other component.Therefore Automatic white balance is exactly by adjusting the gain of three passages of red, green, blue, the white that reaches image display white still under dissimilar illumination conditions, or grey object can colour cast.