Background technology
(human visual system HVS) for the adaptation of prismy color change, is that the mankind have a specific character to the human visual system, and this specific character is perception one white surface and it is used as pure white under the light source condition of different-colour.In order to imitate human visual system's adaptation, when all digitized video sense control assemblies will be obtained digitized video, must have method for controlling white balance and realize human digitized video at the similar image that really perceives at that moment.
Fig. 1 is the flow chart of steps of the method for controlling white balance of a traditional use total image, at first, sets an initial white balance and sets, shown in step S10.Secondly, shown in step S12, obtain an image according to this white balance setting.Shown in step S14, obtain the average RGB value of total image.Shown in step S16, use the average RGB value of total image to calculate white balance information.
Shown in step S18, use white balance information to decide the light and shade situation of current white balance state around whether realistic.Shown in step S20, set if need not change current white balance, then program is back to step S12 and obtains a new image, otherwise execution in step S22 then.Shown in step S22, if showing, the result who is determined need select a new white balance state, then set a new white balance and set.At last, program is back to the step that obtains a new image and carries out step thereafter.
Fig. 2 is the flow chart of steps of the method for controlling white balance of another traditional use white pixel, at first, sets an initial white balance and sets, shown in step S40.Secondly, shown in step S42, obtain an image according to this white balance setting.Shown in step S44, find out the white pixel in the image.Shown in step S46, obtain the average RGB value of white pixel.Shown in step S48, use the average RGB value of white pixel to calculate white balance information.
Shown in step S50, use white balance information to decide the light and shade situation of current white balance state around whether realistic.Shown in step S52, set if need not change current white balance, then program is back to step S42 and obtains a new image, otherwise execution in step S54 then.Shown in step S54, if showing, the result who is determined need select a new white balance state, then set a new white balance and set.At last, program is back to the step that obtains a new image and carries out step thereafter.
Though above-mentioned two method for controlling white balance of commonly using are widely used, they distinctly have some shortcomings.In first method, when obtained scenery, when for example being the scenery in the setting sun, forest or blue sky, in these scenery, has the color of some master controls, and when the white balance information of using the total image RGB decides current white balance state, can cause incorrect white balance to judge.The result can make image be corrected and have identical average RGB value and seem nature.In the second approach, when the white pixel number that is found does not surpass the certain ratio of overall number of pixels, and when the white balance information of using the white pixel RGB decides current white balance state, be difficult to obtain correct result.
Embodiment
The present invention is a kind of method for controlling white balance, control method shown in its integration map 1 and Fig. 2 and the program that add to strengthen and form a kind of more perfect and more can accurately react around the novel method for controlling white balance of light and shade situation.
Fig. 3 is the flow chart of the step of method for controlling white balance of the present invention, at first, sets an initial white balance and sets, shown in step S110.
Secondly, shown in step S112, obtain an image according to this white balance setting.Shown in step S114, S144 and S146, obtain both average RGB values of total image and white pixel.Shown in step S116 and S148, use both average RGB values of total image and white pixel to calculate white balance information respectively.
Again secondly, shown in step S118, use the white balance information of total image and both RGBs of white pixel to decide the light and shade situation of current white balance state around whether realistic.Shown in step S120, set if need not change current white balance, then program is back to step S112, otherwise execution in step S122 then.Shown in step S122, if showing, the result who is determined need select a new white balance state, then set a new white balance and set.
At last, program is back to step and the execution step thereafter that obtains a new image.
Fig. 4 is the flow chart of step of a preferred embodiment of method for controlling white balance of the present invention, and its whole control program is divided into four key steps.
Shown in step Step I, the method for controlling white balance of this preferred embodiment is to set initial state for.In regular turn shown in step S200, S202, S204 and S206, these initial states comprise selects several white balance state of a controls n, select several white balance situation bias voltages for white balance state of a control Status 1 to Status n, select an initial white balance state of a control Status S, and load one group of white balance situation bias voltage for white balance state of a control Status S.The white balance situation bias voltage of these white balance state of a controls Status 1 to Status n is obtained according to empirical value.
Fig. 5 is the skeleton diagram that illustrates the white balance state of a control of difference.As shown in Figure 5, the number of selected white balance state of a control is n, and this is that expression has the white balance setting of n state with on every side the light and shade situation of reaction by the low paramount colour temperature of colour temperature.For the white balance state of a control Status (n-1) of difference to the situation bias voltage of the difference of Status n be to be expressed as T
(n-1), n, and the situation bias voltage of the difference of Status n to Status (n-1) is to be expressed as T
N, (n-1)
Shown in step Step II, obtain an image according to a current white balance state of a control, shown in step S208.Have two groups of white balance information in this as shown in the figure.Afterwards, obtain information, reach shown in the step as described below for decision white balance state of a control institute palpus.Shown in step S210, first group of white balance information obtained by total image, comprises average total image RGB value R
1, G
1And B
1Shown in step S212, first group of white balance acquisition value comprises the first red acquisition value Rg
1And the first blue acquisition value Bg
1Shown in step S214, average total image legibility Y.White balance acquisition value Rg
1And Bg
1Respectively by Rg
1=G
1/ R
1And Bg
1=G
1/ B
1Institute is given.And legibility Y is by Y=C
1XR
1+ C
2XG
1+ C
3XB
1Institute is given, wherein C
1+ C
2+ C
3=1.
Shown in step S220 and S222, second group of white balance information obtained by the white pixel in the image, comprises average white pixel RGB value R
2, G
2And B
2Shown in step S224, second group of white balance acquisition value comprises the second red acquisition value Rg
2And the second blue acquisition value Bg
2Shown in step S226, the number C of white pixel
WBWhite balance acquisition value Rg
2And Bg
2Respectively by Rg
2=G
2/ R
2And Bg
2=G
2/ B
2Institute is given.
Shown in step Step III, the white balance information that is obtained by step Step II is with deciding current white balance state whether can react actual light and shade situation on every side, shown in step S250.Fig. 6 is the flow chart of a preferred version of the thin portion of the determination procedure among step S250 content, with the number C of white pixel
WBWith a situation bias voltage Th
cCompare, shown in step S300.If the number C of white pixel
WBSurpass situation bias voltage Th
c, then program execution in step S310 uses the white balance information of white pixel RGB to decide white balance to set.Otherwise, if the number C of white pixel
WBDo not surpass situation bias voltage Th
c, then program execution in step S400 uses the white balance information of total image RGB to decide white balance to set.Use this determination procedure can guarantee in an image, to have enough and can react light and shade situation on every side by detected white pixel number.
Shown in step S310, if do not have enough can detected white pixel number and present state Status S be not equal to n (not being to be positioned at high state), program execution in step S320 then is with second group of white balance acquisition value Rg
2And Bg
2With a situation bias voltage T2
S, (s+1)Compare.Shown in step S330, if this relatively determines program execution in step S510 then; Otherwise program execution in step S340 then.Shown in step S510, white balance state of a control Status S changes over S=S+1 and a flag signals Flag sets 1 for to indicate the white balance state of a control to change.If step S330's relatively is that undetermined or present state Status S equals n, then program execution in step S340.Shown in step S340, check whether Status S equals 1, if Status S is not equal to 1, program execution in step S350 then.Shown in step S350, with second group of white balance acquisition value Rg
2And Bg
2With a situation bias voltage T2
S, (s-1)Compare.Shown in step S360, relatively determine as if above-mentioned, then program execution in step S520; Otherwise program execution in step S530 then.Shown in step S520, white balance state of a control Status S changes over S=S-1 and flag signals Flag sets 1 for.If step S360's relatively is that undetermined or present state Status S equals 1, then program execution in step S530.Shown in step S530, current white balance is set and will do not changed, that is S=S and Flag=0.
White balance acquisition value Rg
2And Bg
2With situation bias voltage T2
S, (s+1)One real example of comparing is given Rg
2>=1.00 and Bg
2<=1.00, when around the light and shade situation demonstrate the situation of being reacted and have higher colour temperature than current white balance state of a control Status S, then above-mentionedly relatively determine.In addition, Rg
2And Bg
2With situation bias voltage T2
S, (s-1)One real example of comparing is given Rg
2<=1.00 and Bg
2>=1.00, when around the light and shade situation demonstrate the situation of being reacted and have lower colour temperature than current white balance state of a control Status S, then above-mentionedly relatively determine.In addition, second group of white balance acquisition value Rg
2And Bg
2And the comparison between the situation bias voltage is stated more than not bright for restriction, can also select different comparisons or other situation bias voltage for use.
In obtained image, do not have under the situation of enough white pixel numbers, use the white balance information of total image RGB to decide white balance to set, at first, shown in the step S400 of Fig. 6, with an average total image legibility Y and a situation bias voltage Th
YCheck with verification legibility Y whether have effective color information enough greatly, if legibility Y is not more than situation bias voltage Th
YProgram execution in step S530 then, white balance is set and will do not changed and Flag is set as 0; Otherwise program execution in step S410 then.Shown in step S410, if legibility Y is greater than situation bias voltage Th
YAnd present white balance state of a control Status S is not equal to n, then program execution in step S420.Shown in step S420, with first group of white balance acquisition value Rg
1And Bg
1With a situation bias voltage T1
S, (s+1)Compare.Shown in step S430, if this relatively determines program execution in step S510 then; Otherwise program execution in step S440 then.Shown in step S510, white balance state of a control S=S+1 and flag signals Flag set 1 for.If step S430's relatively is that undetermined or present state Status S equals n, then program execution in step S440.Shown in step S440, check whether Status S equals 1, if Status S is not equal to 1, program execution in step S450 then.Shown in step S450, with first group of white balance acquisition value Rg
1And Bg
1With a situation bias voltage T1
S, (s-1)Compare.Shown in step S460, relatively determine as if above-mentioned, then program execution in step S520; Otherwise program execution in step S530 then.Shown in step S520, white balance state of a control Status S changes over S=S-1 and flag signals Flag sets 1 for.If step S460's relatively is that undetermined or present state Status S equals 1, then program execution in step S530.
White balance acquisition value Rg
1And Bg
1With situation bias voltage T2
S, (s+1)One real example of comparing is given [Rg
1<2.5 and Bg
1>0.5 and (Rg
1>=1.0 or Bg
1<1.0)].On the other hand, Rg
1And Bg
1With situation bias voltage T2
S, (s-1)One real example of comparing is given [Rg
1>0.5 and Bg
1<2.5 and (Rg
1<1.0 or Bg
1>=1.0)].Above-mentioned these relatively can be guaranteed to reduce the effect that the color of some master control causes in the image and have influence on status accuracy relatively.In addition, first group white balance acquisition value and the comparison between the situation bias voltage are stated more than not bright for restriction, can also select different comparisons or other situation bias voltage for use.
Shown in the step StepIV of Fig. 4, after the white balance state of a control, shown in step S260, set if need change current white balance, then program execution in step S270; Otherwise set if need not change current white balance, then program is back to step Step II.Shown in step S270, set a new white balance state.Shown in step S280, for new one group of white balance situation of white balance state load bias voltage, and program is back to step Step II.
In sum, can correctly determine the light and shade situation on every side of different-colour, so can accurately adjust white balance according to light and shade situation on every side according to the present invention.