Summary of the invention
In order to solve the problems of the prior art, the invention provides a kind of image processing method and system.
The invention provides a kind of image processing method, comprise automatic explosion method, described automatic explosion method following steps:
Brightness statistics step: image is divided into a plurality of range statistics mean flow rates, each region is gone out to the mean flow rate of whole two field picture according to the weight calculation of appointment in weight table, the mean flow rate of adding up nearest some two field pictures is as with reference to brightness;
Adjust exposure determining step: according to described reference brightness and object brightness, judge whether to adjust exposure, if will adjust exposure, carry out the overall gain step of obtaining setting;
Obtain the overall gain step of setting: with exposure ratio and current overall gain, draw the overall gain of setting, the current overall gain of overall gain=exposure ratio * arranging;
Obtaining step: use the overall gain and the exposure Policy Table that arrange to draw time for exposure and gain;
Step of exposure: the time for exposure in obtaining step and gain are set in imageing sensor and are exposed.
As a further improvement on the present invention, in described adjustment exposure determining step: if reference brightness in the higher limit of object brightness and the scope of lower limit, does not need to adjust exposure; If reference brightness exceeds the higher limit of object brightness and the scope of lower limit, need to adjust exposure.
As a further improvement on the present invention, in the described overall gain step of obtaining setting:
In described exposure ratio, according to reference brightness and object brightness phase extent, adjust exposure ratio, exposure ratio=F (abs(object brightness-reference brightness));
In current overall gain, by the time for exposure, divided by exposure gain Conversion of measurement unit, be first exposure gain, then exposure gain * gain is obtained to current overall gain.
As a further improvement on the present invention, in described obtaining step, the project of described exposure Policy Table's list item comprises:
Maximum exposure gain, the maximum exposure that can reach for this section of exposure gain;
Maximum gain, the maximum gain that can reach for this section of exposure;
Maximum overall gain, the maximum overall gain that can reach for this section of exposure, maximum overall gain=maximum exposure gain * maximum gain;
Exposure mode, for this section of exposure mode that exposure is used, is divided into two kinds of exposure gain mode and gain modes; Exposure gain mode, gain keeps maximum gain constant, and exposure gain changes between the gain of 0~maximum exposure; Gain mode, time for exposure gain keeps maximum exposure gain constant, and gain changes between 1~maximum gain;
In described obtaining step, comprise execution following steps:
First from exposure Policy Table, search the list item that first maximum overall gain is more than or equal to the overall gain that will arrange;
Judge again the exposure mode of the list item that this searches: the gain mode that exposes if, gain=maximum gain, maximum exposure gain=overall gain/gain; Gain mode, exposure gain=maximum gain, gain=overall gain/exposure gain if;
Then, the gain conversions of exposing is the time for exposure, time for exposure=exposure gain * exposure gain unit.
As a further improvement on the present invention, this image processing method also comprises auto white balance method, and described auto white balance method comprises execution following steps:
A.R, G, B white balance statistics, for counting green red ratio G/R and the turquoise ratio G/R of present image;
B. according to statistical information, estimate current colour temperature, for according to green red ratio G/R and turquoise ratio G/R and the color temperature estimation function of statistics, estimate current colour temperature;
C. according to the colour temperature of estimating and the corresponding red blue gain of white balance and color correction matrix of high, medium and low three colour temperatures, interpolation goes out the red blue gain of current white balance and color correction matrix;
D., the red blue gain of white balance and color correction matrix are set.
The present invention also provides a kind of image processing system, comprises automatic exposure unit, and described automatic exposure unit comprises:
Brightness statistic: for image being divided into a plurality of range statistics mean flow rates, each region is gone out to the mean flow rate of whole two field picture according to the weight calculation of appointment in weight table, the mean flow rate of adding up nearest some two field pictures is as with reference to brightness;
Adjust exposure judge module: for judging whether to adjust exposure according to described reference brightness and object brightness, if will adjust exposure, carry out the overall gain module of obtaining setting;
Obtain the overall gain module of setting: with exposure ratio and current overall gain, draw the overall gain of setting, the current overall gain of overall gain=exposure ratio * arranging;
Acquisition module: for using overall gain and the exposure Policy Table of setting to draw time for exposure and gain;
Exposure module: for the time for exposure of acquisition module and gain are set in imageing sensor and are exposed.
As a further improvement on the present invention, in described adjustment exposure judge module: if reference brightness in the higher limit of object brightness and the scope of lower limit, does not need to adjust exposure; If reference brightness exceeds the higher limit of object brightness and the scope of lower limit, need to adjust exposure.
As a further improvement on the present invention, in the described overall gain module of obtaining setting:
In described exposure ratio, according to reference brightness and object brightness phase extent, adjust exposure ratio, exposure ratio=F (abs(object brightness-reference brightness));
In current overall gain, by the time for exposure, divided by exposure gain Conversion of measurement unit, be first exposure gain, then exposure gain * gain is obtained to current overall gain.
As a further improvement on the present invention, in described acquisition module, the project of described exposure Policy Table's list item comprises:
Maximum exposure gain, the maximum exposure that can reach for this section of exposure gain;
Maximum gain, the maximum gain that can reach for this section of exposure;
Maximum overall gain, the maximum overall gain that can reach for this section of exposure, maximum overall gain=maximum exposure gain * maximum gain;
Exposure mode, for this section of exposure mode that exposure is used, is divided into two kinds of exposure gain mode and gain modes; Exposure gain mode, gain keeps maximum gain constant, and exposure gain changes between the gain of 0~maximum exposure; Gain mode, time for exposure gain keeps maximum exposure gain constant, and gain changes between 1~maximum gain;
In described acquisition module, comprising:
Search module, for searching from exposure Policy Table the list item that first maximum overall gain is more than or equal to the overall gain that will arrange;
Judge module, for judging the exposure mode of the list item that this searches: the gain mode that exposes if, gain=maximum gain, maximum exposure gain=overall gain/gain; Gain mode, exposure gain=maximum gain, gain=overall gain/exposure gain if;
Modular converter, is the time for exposure for the gain conversions of exposing, time for exposure=exposure gain * exposure gain unit.
As a further improvement on the present invention, this image processing system also comprises Automatic white balance unit, and described Automatic white balance unit comprises:
White balance statistics module, for R, G, B white balance statistics, counts green red ratio G/R and the turquoise ratio G/R of present image;
Estimate current colour temperature module, for estimate current colour temperature according to statistical information, for according to green red ratio G/R and turquoise ratio G/R and the color temperature estimation function of statistics, estimate current colour temperature;
Interpolating module, for gaining and color correction matrix according to the colour temperature of estimating and the red indigo plant of white balance corresponding to high, medium and low three colour temperatures, interpolation goes out the red blue gain of current white balance and color correction matrix;
Module is set, for the red blue gain of white balance and color correction matrix are set.
The invention has the beneficial effects as follows: automatic explosion method of the present invention and unit have improved the unsettled problem of exposure well, the different exposure strategy by customization reaches optimum the image effect under varying environment simultaneously.
Embodiment
The invention discloses a kind of image processing method, comprise automatic explosion method and auto white balance method.As shown in Figure 1, the schematic diagram of automatic explosion method and auto white balance method in the present invention, automatic exposure module obtains graph data from imageing sensor and carries out automatic exposure, then the time for exposure calculating and gain are established into imageing sensor and exposed, Automatic white balance module obtains graph data from imageing sensor and carries out Automatic white balance.
Described automatic explosion method following steps:
Brightness statistics step: image is divided into a plurality of range statistics mean flow rates, each region is gone out to the mean flow rate of whole two field picture according to the weight calculation of appointment in weight table, the mean flow rate of adding up nearest some two field pictures is as with reference to brightness;
Adjust exposure determining step: according to described reference brightness and object brightness, judge whether to adjust exposure, if will adjust exposure, carry out the overall gain step of obtaining setting;
Obtain the overall gain step of setting: with exposure ratio and current overall gain, draw the overall gain of setting, the current overall gain of overall gain=exposure ratio * arranging;
Obtaining step: use the overall gain and the exposure Policy Table that arrange to draw time for exposure and gain;
Step of exposure: the time for exposure in obtaining step and gain are set in imageing sensor and are exposed.
In described adjustment exposure determining step: if reference brightness in the higher limit of object brightness and the scope of lower limit, does not need to adjust exposure; If reference brightness exceeds the higher limit of object brightness and the scope of lower limit, need to adjust exposure.
In the described overall gain step of obtaining setting:
In described exposure ratio, according to reference brightness and object brightness phase extent, adjust exposure ratio, exposure ratio=F (abs(object brightness-reference brightness));
In current overall gain, by the time for exposure, divided by exposure gain Conversion of measurement unit, be first exposure gain, then exposure gain * gain is obtained to current overall gain.
In described obtaining step, the project of described exposure Policy Table's list item comprises:
Maximum exposure gain, the maximum exposure that can reach for this section of exposure gain;
Maximum gain, the maximum gain that can reach for this section of exposure;
Maximum overall gain, the maximum overall gain that can reach for this section of exposure, maximum overall gain=maximum exposure gain * maximum gain;
Exposure mode, for this section of exposure mode that exposure is used, is divided into two kinds of exposure gain mode and gain modes; Exposure gain mode, gain keeps maximum gain constant, and exposure gain changes between the gain of 0~maximum exposure; Gain mode, time for exposure gain keeps maximum exposure gain constant, and gain changes between 1~maximum gain;
In described obtaining step, comprise execution following steps:
First from exposure Policy Table, search the list item that first maximum overall gain is more than or equal to the overall gain that will arrange;
Judge again the exposure mode of the list item that this searches: the gain mode that exposes if, gain=maximum gain, maximum exposure gain=overall gain/gain; Gain mode, exposure gain=maximum gain, gain=overall gain/exposure gain if;
Then, the gain conversions of exposing is the time for exposure, time for exposure=exposure gain * exposure gain unit.
In automatic explosion method of the present invention, time for exposure, gain unification, be a variable, be called overall gain; Customize in advance the exposure Policy Table under varying environment; Image is divided into a plurality of range statistics mean flow rates; Each region is gone out to the mean flow rate of whole two field picture according to the weight calculation of appointment in weight table; The mean flow rate of adding up nearest some two field pictures is as with reference to brightness; According to reference brightness and object brightness, judge whether to adjust exposure; According to reference brightness and object brightness phase extent, adjust exposure ratio; With described exposure ratio and current overall gain, draw the overall gain that will arrange; The exposure Policy Table of the overall gain that use will arrange and appointment draws time for exposure, the gain that will arrange; The time for exposure obtaining, gain are established into imageing sensor and exposed.
Time for exposure, gain unification, be an overall gain, method is:
First by the time for exposure, divided by exposure gain Conversion of measurement unit, be exposure gain: ExposureGain=ExposureTime/ExposureGainUnit;
Then the gain that will gain and expose is unified is overall gain: TotalGain=ExposureGain*Gain.
The exposure gain ExposureGainUnit of unit can arbitrarily specify a time for exposure, such as, 10 milliseconds.
Customize in advance the exposure Policy Table under varying environment, each list item of exposure Policy Table has represented one section of exposure-processed, with an exposure Policy Table, an exposure strategy is divided into multistage exposure processing and stores.
According to different environment, customize different exposure Policy Tables in advance, such as, for indoor environment, because can being subject to the light intensity that affects of 50Hz/60Hz alternating current, lighting source periodically changes, for fear of flicker, need to be by the integral multiple in furnishing light source scintillation cycle time for exposure, thereby the exposure strategy of customization indoor mode, for outdoor environment, owing to there not being lighting source, substantially be all the natural daylight of stabilized intensity, more problem be outdoor environment image brightness excessive cause over-exposed, should allow the time for exposure can be short as much as possible for this reason, thereby customize the exposure strategy of outdoor pattern.
The project of exposure Policy Table's list item, comprising:
Maximum exposure gain (MaxExposureGain): the maximum exposure gain that can reach in this section of exposure;
Maximum gain (MaxGain): the maximum gain that can reach in this section of exposure;
Maximum overall gain (MaxTotalGain): the maximum overall gain that can reach in this section of exposure, it equals MaxExposureGain*MaxGain; List item in table is arranged from small to large according to the size of maximum overall gain;
Exposure mode (ExposureMode): exposure mode used in this section of exposure, is divided into two kinds of exposure gain mode and gain modes;
Exposure gain mode, gain keeps MaxGain constant, and exposure gain changes between 0~MaxExposureGain;
Gain mode, time for exposure gain keeps MaxExposureGain constant, and gain changes between 1~MaxGain.
Image is divided into a plurality of range statistics mean flow rates, and region number can arbitrarily be divided, and is generally no less than 5x5.Each region is gone out to the mean flow rate of whole two field picture according to the weight calculation of appointment in weight table.The mean flow rate of adding up nearest some two field pictures is as with reference to brightness.In weight table, can want to see the larger weight in more image detail backlight region to some.
According to reference brightness and object brightness, judge whether will adjust exposure, determination methods:
If reference brightness in the higher limit of object brightness and the scope of lower limit, does not need to adjust exposure;
If reference brightness exceeds the higher limit of object brightness and the scope of lower limit, need to adjust exposure.
For example, judge that reference brightness refY is whether in the higher limit of object brightness tarY and the scope of lower limit, as, lower limit is tarY-5, higher limit tarY+5, judges that refY is whether within the scope of tarY-5~tarY+5, within the scope of this, does not just carry out overall gain calculating and exposure is adjusted.
According to reference brightness (refY) and object brightness (tarY) phase extent, adjust exposure ratio ExpRate, the exposure ratio that differs larger adjustment is larger, and the exposure ratio that differs less adjustment is less, by exposure ratio function, draws:
ExpRate=F(abs(tarY-refY))。
With described exposure ratio and current overall gain, draw the overall gain that will arrange: TotalGain=TotalGain*ExpRate.
The exposure Policy Table of the overall gain that use will arrange and appointment draws time for exposure, the gain that will arrange, and specifically comprises:
First from exposure Policy Table, search the list item that first maximum overall gain MaxTotalGain is more than or equal to the overall gain TotalGain that will arrange;
Judge again the exposure mode of the list item that this searches:
The gain mode that exposes if,
Gain=MaxGain;
ExposureGain=TotalGain/Gain;
Gain mode if,
ExposureGain=MaxGain;
Gain=TotalGain/ExposureGain;
Then, the gain conversions of exposing is the time for exposure,
ExposureTime=ExposureGain*ExposureGainUnit。
The time for exposure obtaining, gain are established into imageing sensor and exposed.
This image processing method also comprises auto white balance method; use in advance colour temperature lamp box and standard color card to measure the red blue gain of white balance corresponding under high, medium and low three colour temperatures and color correction matrix; these selected three colour temperatures need contain the colour temperature in surroundings substantially, are determined as follows:
Under high color temperature, colour temperature is HColorTemp, and the red gain of white balance is HRedGain, and the blue gain of white balance is HBlueGain, and color correction matrix is HColorMatrix;
Under middle colour temperature, colour temperature is MColorTemp, and the red gain of white balance is MRedGain, white balance
Blue gain is MBlueGain, and color correction matrix is MColorMatrix;
Under low colour temperature, colour temperature is LColorTemp, and the red gain of white balance is LRedGain, and the blue gain of white balance is LBlueGain, and color correction matrix is LColorMatrix;
There have been the red blue gain of these three groups of white balances of measuring in advance and color correction matrix, just can have carried out white balance according to the Automatic white balance handling process of Fig. 2.
As shown in Figure 2, described auto white balance method comprises execution following steps:
In step S1, R, G, B white balance statistics, for counting green red ratio G/R and the turquoise ratio G/R of present image;
In step S2, according to statistical information, estimate current colour temperature, for according to green red ratio G/R and turquoise ratio G/R and the color temperature estimation function of statistics, estimate current colour temperature;
In step S3, according to the colour temperature of estimating and the corresponding red blue gain of white balance and color correction matrix of high, medium and low three colour temperatures, interpolation goes out the red blue gain of current white balance and color correction matrix;
In step S4, the red blue gain of white balance and color correction matrix are set.
In step S3, interpolation method can change flexibly, and the most easy method is linear interpolation, specific as follows:
If current colour temperature CColorTemp is between high color temperature and middle colour temperature,
The red gain of current white balance:
The blue gain of current white balance:
Current color correction matrix:
If current colour temperature is between middle colour temperature and low colour temperature,
The red gain of current white balance:
The blue gain of current white balance
Current color correction matrix:
Color correction matrix is the coefficient matrix of 3x3, concrete:
The method of color correction:
New color value after correction=old color value * color correction matrix.
Carry out white balance R, G, B statistics, count green red ratio G/R and the turquoise ratio G/R of present image.
According to statistical information, estimate current colour temperature, be specially according to green red ratio G/R and turquoise ratio G/R and the color temperature estimation function of statistics, estimate current colour temperature.
The invention also discloses a kind of image processing system, comprise automatic exposure unit, described automatic exposure unit comprises:
Brightness statistic: for image being divided into a plurality of range statistics mean flow rates, each region is gone out to the mean flow rate of whole two field picture according to the weight calculation of appointment in weight table, the mean flow rate of adding up nearest some two field pictures is as with reference to brightness;
Adjust exposure judge module: for judging whether to adjust exposure according to described reference brightness and object brightness, if will adjust exposure, carry out the overall gain module of obtaining setting;
Obtain the overall gain module of setting: with exposure ratio and current overall gain, draw the overall gain of setting, the current overall gain of overall gain=exposure ratio * arranging;
Acquisition module: for using overall gain and the exposure Policy Table of setting to draw time for exposure and gain;
Exposure module: for the time for exposure of acquisition module and gain are set in imageing sensor and are exposed.
In described adjustment exposure judge module: if reference brightness in the higher limit of object brightness and the scope of lower limit, does not need to adjust exposure; If reference brightness exceeds the higher limit of object brightness and the scope of lower limit, need to adjust exposure.
In the described overall gain module of obtaining setting:
In described exposure ratio, according to reference brightness and object brightness phase extent, adjust exposure ratio, exposure ratio=F (abs(object brightness-reference brightness));
In current overall gain, by the time for exposure, divided by exposure gain Conversion of measurement unit, be first exposure gain, then exposure gain * gain is obtained to current overall gain.
In described acquisition module, the project of described exposure Policy Table's list item comprises:
Maximum exposure gain, the maximum exposure that can reach for this section of exposure gain;
Maximum gain, the maximum gain that can reach for this section of exposure;
Maximum overall gain, the maximum overall gain that can reach for this section of exposure, maximum overall gain=maximum exposure gain * maximum gain;
Exposure mode, for this section of exposure mode that exposure is used, is divided into two kinds of exposure gain mode and gain modes; Exposure gain mode, gain keeps maximum gain constant, and exposure gain changes between the gain of 0~maximum exposure; Gain mode, time for exposure gain keeps maximum exposure gain constant, and gain changes between 1~maximum gain;
In described acquisition module, comprising:
Search module, for searching from exposure Policy Table the list item that first maximum overall gain is more than or equal to the overall gain that will arrange;
Judge module, for judging the exposure mode of the list item that this searches: the gain mode that exposes if, gain=maximum gain, maximum exposure gain=overall gain/gain; Gain mode, exposure gain=maximum gain, gain=overall gain/exposure gain if;
Modular converter, is the time for exposure for the gain conversions of exposing, time for exposure=exposure gain * exposure gain unit.
This image processing system also comprises Automatic white balance unit, and described Automatic white balance unit comprises:
White balance statistics module, for R, G, B white balance statistics, counts green red ratio G/R and the turquoise ratio G/R of present image;
Estimate current colour temperature module, for estimate current colour temperature according to statistical information, for according to green red ratio G/R and turquoise ratio G/R and the color temperature estimation function of statistics, estimate current colour temperature;
Interpolating module, for gaining and color correction matrix according to the colour temperature of estimating and the red indigo plant of white balance corresponding to high, medium and low three colour temperatures, interpolation goes out the red blue gain of current white balance and color correction matrix;
Module is set, for the red blue gain of white balance and color correction matrix are set.
Automatic explosion method of the present invention and unit have improved the unsettled problem of exposure well, and the different exposure strategy by customization reaches optimum the image effect under varying environment simultaneously; When having carried out the red blue gain of white balance according to colour temperature, auto white balance method of the present invention and unit also introduce color correction matrix, under different-colour, use different color correction matrixes, so greatly improved the white balance colour cast problem due to the impact generation of imageing sensor and filter.
Above content is in conjunction with concrete preferred implementation further description made for the present invention, can not assert that specific embodiment of the invention is confined to these explanations.For general technical staff of the technical field of the invention, without departing from the inventive concept of the premise, can also make some simple deduction or replace, all should be considered as belonging to protection scope of the present invention.