Automatic exposure regulating method and deviceTechnical field
The present invention relates to the image processing field of camera head, especially, relate to a kind of automatic exposure regulating method and device.
Background technology
Under the constant prerequisite of ambient brightness, in the camera head time shutter of imageing sensor long more, image is bright more; Otherwise the time shutter is short more, and image is dark more.And under fixing situation of time shutter, digital gain is big more, and image is bright more; Digital gain is more little, and image is dark more.If scenery is bright excessively in the image, and bright part do not have level or details, is exactly over-exposed; If image is dark, can't truly reflect the color and luster of scenery, be exactly under-exposed.Therefore, when ambient brightness changes, need correspondingly adjust the time shutter, to avoid over-exposed under the bright ring border or under-exposed under dark situation.
In the process of regulating the time shutter,, carry out the automatic exposure adjusting in conjunction with time shutter and digital gain usually in order to guarantee the brightness of image smooth change.The digital gain scope that each grade time shutter is corresponding different, need expose when adjusting, adjust digital gain according to a certain predefined step-length earlier, the backlog demand still if digital gain has gone beyond the scope, then will the time shutter change to next stage, so repeatedly, progressively approach the object brightness of image.
The shortcoming of said method is, adjusts step-length and fixes.If step-length is bigger, be easy to occur the situation that automatic exposure can't lock; If step-length is less, then every adjusting once, the variable quantity of brightness of image is just smaller, like this, when bigger variation takes place ambient brightness, often needs just can finish the exposure adjustment process for a long time.
Summary of the invention
The objective of the invention is to, solve because of adopt fixing adjust exposure governing speed that step-length causes slow or be prone to can't lock condition problem.
According to a first aspect of the invention, provide a kind of automatic exposure regulating method, said method comprising the steps of: (1) judges whether present image is in the lock state; (2) under the situation that present image is not in the lock state, determine the adjustment step-length (Step) of time shutter and/or digital gain according to the present image mean flow rate (Ymean) and the difference of target image brightness (Ytarget); And (3) adjust time shutter and/or digital gain according to described adjustment step-length (Step).
In first aspect, preferably, in step (2), under the situation of present image mean flow rate (Ymean) less than target image brightness (Ytarget), ((Ytarget-Ylock)-Ymean) * SpeedFactor+D determines described adjustment step-length (Step) to utilize formula S tep=, wherein Ylock represents lock-in range, and SpeedFactor represents to regulate the speed, and D is a constant.More preferably, reached under the peaked situation, determined the adjustment step-length (Step) of digital gain in the time shutter.
Preferably, in step (2), under the situation of present image mean flow rate (Ymean) greater than target image brightness (Ytarget), utilize formula S tep=(Ymean-(Ytarget+Ylock)) * SpeedFactor+D to determine described adjustment step-length (Step), wherein Ylock represents lock-in range, SpeedFactor represents to regulate the speed, and D is a constant.
Preferably, in step (2), under outdoor pattern, digital gain is made as fixed value, determines the adjustment step-length (Step) of time shutter.
Preferably, described D is 1.
Preferably, described SpeedFactor is less than 1.
Preferably, in step (2), under the situation that present image is not in the lock state, difference and the threshold value of present image mean flow rate (Ymean) with target image brightness (Ytarget) compared, and under the situation of described difference, determine the adjustment step-length (Step) of time shutter and/or digital gain according to described difference greater than this threshold value.
According to second aspect, a kind of automatic exposure regulating device is provided, described device comprises: the lock-out state judgment means is used to judge whether present image is in the lock state; Adjust step-length and determine device, be used under the situation that present image is not in the lock state, determine the adjustment step-length (Step) of time shutter and/or digital gain according to the present image mean flow rate (Ymean) and the difference of target image brightness (Ytarget); And adjusting gear, be used for adjusting time shutter and/or digital gain according to described adjustment step-length (Step).
In second aspect, preferably, described adjustment step-length determines that device is under the situation of present image mean flow rate (Ymean) less than target image brightness (Ytarget), ((Ytarget-Ylock)-Ymean) * SpeedFactor+D determines described adjustment step-length (Step) to utilize formula S tep=, wherein Ylock represents lock-in range, SpeedFactor represents to regulate the speed, and D is a constant.More preferably, described adjustment step-length determines that device reached under the peaked situation in the time shutter, determines the adjustment step-length (Step) of digital gain.
Preferably, described adjustment step-length determines that device is under the situation of present image mean flow rate (Ymean) greater than target image brightness (Ytarget), utilize formula S tep=(Ymean-(Ytarget+Ylock)) * SpeedFactor+D to determine described adjustment step-length (Step), wherein Ylock represents lock-in range, SpeedFactor represents to regulate the speed, and D is a constant.
Preferably, described adjustment step-length determines that device is made as fixed value with digital gain under outdoor pattern, determines the adjustment step-length (Step) of time shutter.
According to the third aspect, a kind of camera head is provided, described camera head comprises as the described automatic exposure regulating device of second aspect.
The present invention adopts variable adjustment step-length, and the difference of adjusting step-length and present image brightness and target image brightness is associated, and makes between the difference of adjusting step-length and present image brightness and target image brightness linear.Like this, under present image brightness and target image brightness differed situation far away, step-length was adjusted in corresponding increase, thereby has improved the exposure governing speed.Simultaneously, also effectively avoided can't lock condition generation.
Description of drawings
For understanding the present invention better, the invention will be further described below in conjunction with the drawings and specific embodiments, in the accompanying drawing:
Fig. 1 is for judging the synoptic diagram whether present image is in the lock state;
Fig. 2 is the process flow diagram of the automatic exposure regulating method of an embodiment of the present invention.
Embodiment
With reference to Fig. 2, Fig. 2 shows the flow process of the automatic exposure regulating method of an embodiment of the present invention.Realize the automatic exposure adjustment process, at first judge whether the adjustment that to expose.At step S21, obtain present image mean flow rate Ymean, here, " mean flow rate " comprises the weighted mean brightness that weights are different; At step S22, judge whether present image is in the lock state, as be in the lock state, then do not need to carry out automatic exposure and regulate.This deterministic process is judged identical with the locking in the method that adopts fixing adjustment step-length.
With reference to Fig. 1, Fig. 1 is for judging the synoptic diagram whether present image is in the lock state.Wherein, Ytarget represents target image brightness; Ylock represents the lock-in range of automatic exposure; Yunlock represents the non-locking scope of automatic exposure.Under lock-out state, if | Ymean-Ytarget|>Yunlock, then enter unlock state, need carry out automatic exposure and regulate, otherwise still keep lock-out state; Under unlock state, if | Ymean-Ytarget|<Ylock, then enter lock-out state, otherwise still be in unlock state, proceed automatic exposure and regulate.
According to the present invention, under the situation of non-locking, the automatic exposure adjusting is divided into three kinds of states: state one, the time shutter has reached maximal value, and present image mean flow rate Ymean is less than target image brightness Ytarget; State two, promptly outdoor pattern, this following time shutter of pattern is less than the period of change of interior lighting system intensity of illumination; State three, normal mode, i.e. other states except state one, two.
Referring again to Fig. 2,, judge whether described unlock state belongs to state one at step S23.If belong to state one,, can only further increase present image mean flow rate Ymean by improving digital gain because of the time shutter can not increase again.Usually, in order to see the scene under the dark situation more clearly, the maximum one-level time shutter, the pairing digital gain upper limit will suitably be increased to a mxm..At this moment, at step S24, can determine the adjustment step-length Step of digital gain by following formula:
((Ytarget-Ylock)-Ymean) * SpeedFactor+D (1) wherein D is a constant to Step=, and SpeedFactor represents that automatic exposure regulates the speed (in (5), identical parameters is represented identical meanings at following formula (2)).Here, in general, automatic exposure is regulated the speed the value of SpeedFactor less than 1.
If judge not belong to state one,, judge further whether described unlock state belongs to state two next at step S25.If belong to state two, then behind the inlet chamber external schema, (indoor mode is for avoiding occurring flicker much smaller than indoor mode because of the difference of adjacent two-stage time shutter, time shutter must be the integral multiple of the period of change of illuminator intensity of illumination), digital gain can be fixed as default value GainDefault, and only adjust the time shutter.At step S26, under the situation of present image mean flow rate Ymean, can determine the adjustment step-length Step of time shutter by following formula less than target image brightness Ytarget:
Step=((Ytarget-Ylock)-Ymean) * SpeedFactor+D (2) and under the situation of present image mean flow rate Ymean, can determine the adjustment step-length Step of time shutter by following formula greater than target image brightness Ytarget:
Step=(Ymean-(Ytarget+Ylock))*SpeedFactor+D (3)
If judge not belong to state two, then described unlock state belongs to state three.For state three, described adjustment step-length is no longer only at digital gain or time shutter, but with both considerations of uniting.Pairing adjustable digital gain scope of n level time shutter under the normal mode is expressed as [GainDefault-GainRange[n-1], GainDefault+GainRange[n-1]], particularly, first adjusts level cooperates corresponding with it lowest numeric gain G ainDefault-GainRange[0 for the first order time shutter], second adjusts level cooperates digital gain GainDefault-GainRange[0 for the first order time shutter]+1, so go down, m adjusts level and cooperates corresponding with it maximum number gain G ainDefault+GainRange[0 for the first order time shutter]; Next, m+1 adjusts level and cooperates corresponding with it lowest numeric gain G ainDefault-GainRange[1 for the second level time shutter], by that analogy.Following table shows the adjustment level of state three:
| Adjust level | The time shutter level | Digital gain |
| 1 | 1 | GainDefault-GainRange[0] |
| 2 | 1 | GainDefault-GainRange[0]+1 |
| …… | …… | …… |
| 2*GainRange[0]+1 | 1 | GainDefault+GainRange[0] |
| 2*GainRange[0]+2 | 2 | GainDefault-GainRange[1] |
| 2*GainRange[0]+3 | 2 | GainDefault-GainRange[1]+1 |
| …… | …… | …… |
| 2*GainRange[0]+1+2* GainRange[1]+1 | 2 | GainDefault+GainRange[1] |
| 2*GainRange[0]+1+2* GainRange[1]+2 | 3 | GainDefault-GainRange[2] |
| …… | …… | …… |
Then, under the situation of present image mean flow rate Ymean, can determine to adjust step-length Step by following formula less than target image brightness Ytarget at step S27:
Step=((Ytarget-Ylock)-Ymean) * SpeedFactor+D (4) and under the situation of present image mean flow rate Ymean greater than target image brightness Ytarget, can determine to adjust step-length Step by following formula:
Step=(Ymean-(Ytarget+Ylock)) * SpeedFactor+D (5) just can adjust time shutter and digital gain after treating that described adjustment step-length is determined.
To formula (5), preferably, constant D is 1 in above-mentioned formula (1), to avoid occurring always nearly can't entering the situation of lock-out state, makes adjustment step-length Step be at least 1.Certainly, constant D also can be other values except 1, and this is obvious to those skilled in the art.
Be noted that under various states, the brightness of image in the automatic exposure adjustment process changed to give subjective sensation preferably that above-mentioned formula (1) to the automatic exposure in the formula (5) the SpeedFactor parameter of regulating the speed can be got different values.Why need different Speedfactor values, adjust the caused brightness of level with each and change different relevant.For example for some sensor, concerning with the corresponding adjustment level of less time shutter level, the caused brightness of image variation of every adjustment one-level is less than and the corresponding adjustment level of time shutter level greatly.Under such condition, when (Ymean>Ytarget), the current time shutter is bigger, changes the caused brightness of some adjustment progression and changes greatly, just can consider to establish the Speedfactor value littler when very dark environment enters very bright environment.On the contrary, as (Ymean<Ytarget), the Speedfactor value can be established greatly when very bright environment enters very dark environment.
In view of the response difference of various sensors, the subjective sensation of different people is also incomplete same under the same terms, adopts different Speedfactor values to provide greater flexibility for enforcement of the present invention at different situations.Certainly, the also desirable identical value of Speedfactor in all cases.
Sometimes, do not have to arrive under the situation to a certain degree greatly, may not wish to accelerate the automatic exposure governing speed in the difference of present image mean flow rate and target image brightness.In this case, preferably, can set a threshold value FastThd, be used to judge whether to carry out the rapid adjustment of variable step size.When | Ymean-Ytarget|<FastThd, still adopt predefined fixed step size to adjust; When | Ymean-Ytarget|>FastThd, adopt variable step size of the present invention to adjust.
Automatic exposure regulating method of the present invention can be applied to include but not limited in the camera heads such as PC camera, mobile phone cam, monitoring camera and digital camera with device.
Obviously, the present invention described here can have many variations.For example, in above-mentioned embodiment, though judge whether to belong to state two again after judging whether to belong to state one, those skilled in the art are understandable to be, also can judge whether to belong to state one again after judging whether to belong to state two.These variations can not think and depart from the spirit and scope of the present invention that therefore, the change that all it will be apparent to those skilled in the art all is included within the covering scope of the claims of enclosing.