CN109246406B - Method for realizing automatic white balance of color camera - Google Patents
Method for realizing automatic white balance of color camera Download PDFInfo
- Publication number
- CN109246406B CN109246406B CN201811365142.2A CN201811365142A CN109246406B CN 109246406 B CN109246406 B CN 109246406B CN 201811365142 A CN201811365142 A CN 201811365142A CN 109246406 B CN109246406 B CN 109246406B
- Authority
- CN
- China
- Prior art keywords
- gain
- component
- frame image
- white balance
- current frame
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 30
- 238000006243 chemical reaction Methods 0.000 claims abstract description 8
- 101000912561 Bos taurus Fibrinogen gamma-B chain Proteins 0.000 claims description 6
- 230000005540 biological transmission Effects 0.000 claims description 3
- 238000013139 quantization Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 238000005286 illumination Methods 0.000 description 1
- 230000003595 spectral effect Effects 0.000 description 1
- WFKWXMTUELFFGS-UHFFFAOYSA-N tungsten Chemical compound [W] WFKWXMTUELFFGS-UHFFFAOYSA-N 0.000 description 1
- 229910052721 tungsten Inorganic materials 0.000 description 1
- 239000010937 tungsten Substances 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N23/00—Cameras or camera modules comprising electronic image sensors; Control thereof
- H04N23/80—Camera processing pipelines; Components thereof
- H04N23/84—Camera processing pipelines; Components thereof for processing colour signals
- H04N23/88—Camera processing pipelines; Components thereof for processing colour signals for colour balance, e.g. white-balance circuits or colour temperature control
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Processing Of Color Television Signals (AREA)
- Color Television Image Signal Generators (AREA)
Abstract
The invention relates to a method for realizing automatic white balance of a color camera. The method improves the convergence speed of the automatic white balance algorithm of the color camera. The method mainly comprises the following steps: 1. obtaining a current gain and target gain relational expression according to the RGB and YCbCr space conversion relation; 2. detecting white points of the current frame image; 3. estimating the color temperature of the current frame image N, and judging whether color cast occurs or not; 4. calculating a target gain according to the current gain and the target gain relational expression in the step 1; 5. the gain adjustment is made for the R, B components of each pel of the N +2 frame image.
Description
Technical Field
The invention relates to an image processing technology, in particular to a method for realizing automatic white balance of a hue machine.
Background
The basic concept of white balance is to restore a white object to white regardless of the light source. The spectral characteristics are different from each other under different light sources or weather conditions, which is called color temperature. Physically, a person sees an object in a particular color because light reflected from the object appears in the human visual system when the light is directed at the object. That is, the color of an object that can be seen depends not only on its reflective properties, but also on the light directed at the object, e.g., a piece of white paper will be orange under tungsten light, green under fluorescent light, and somewhat blue under sunlight. The purpose of automatic white balance is to automatically adjust the proportion of the three primary color components of the image under different color temperature illumination, so that the image looks consistent with the color shot under a standard light source.
Many color cameras with an automatic white balance function perform color temperature evaluation on images in a YCbCr space, and then adjust the gain values of Cb and Cr to make Cb and Cr meet the conditions of white pixel points, thereby completing the automatic white balance function, so that the adjustment method of the Cb and Cr gains is a key point of automatic white balance.
The existing method adjusts the gain step by setting the step length, but when the method is adopted for adjustment, the convergence speed is low, and the use requirement of a high-frequency camera cannot be met.
Disclosure of Invention
In order to overcome the defects of the prior art in the background art, the invention provides a method for realizing automatic white balance of a color camera, which improves the speed of fast convergence of the automatic white balance of the color camera.
The specific technical scheme of the invention is as follows:
a method for realizing automatic white balance of a color camera runs on a processor of the color camera, and the processor is of an FPGA (field programmable gate array) or a CPU (central processing unit) or a DSP (digital signal processor); the method is realized by the following steps:
【1】 Acquiring a relational expression of a current gain R component gain gamma and a target gain R component gain gamma 'and a relational expression of a current gain B component gain alpha and a target gain B component gain alpha' according to the space conversion relation between RGB and YCbCr;
the concrete formula is as follows:
【2】 Setting a white point number threshold value w, detecting each pixel of the current frame image N, judging whether the pixel is a white point, counting the number w 'of the detected white points of the current frame image N, comparing the detected white point number w' of the current frame image N with the white point number threshold value w, if w 'is more than or equal to w, performing the step (3), and if w' is less than w, performing the step (6);
【3】 Estimating the color temperature of the current frame image N, and judging whether color cast occurs or not;
calculating the average value of all white points of the current frame image NAnd
if it is notIf M is set to be 9, judging that the image has color cast, and adjusting the gain of the component B or R, and entering the step (4);
if it is notJudging that the image has no color cast, and entering the step (6);
【4】 When in useCalculating a target gain R component gain gamma' according to a formula (1); when in useCalculating a target gain B component gain alpha' according to a formula (2);
【5】 And (4) carrying out white balance adjustment on the current frame image through the target gain R component gain gamma 'or the target gain B component gain alpha' obtained in the step (4).
【6】 After waiting for the 1 frame image transmission, the steps [ 2 ] to [ 5 ] are repeated from the N +2 frame image.
Further, in the step [ 3 ], the judgment condition that any pixel in the current frame image N is a white point is as follows: y is more than or equal to A, | Cb | is less than or equal to B, | Cr | is less than or equal to C; wherein, A is 2048, B is 10 and C is 20. Since the number of quantization bits of a camera implementing this method is 12 bits, the range of the gradation value is 0 to 4095, and the value of a is set to half of the range of the gradation value in this method, a is set to 2048.
Further, the threshold number of white points must be enough to ensure the effect and correctness of white balance, where w is set to 1/500 of the total number of pixels;
the invention has the beneficial effects that:
the invention adopts the method of directly calculating the gain to ensure that the automatic white balance can be converged quickly, the convergence can be realized through 2 or several frame periods, and the white balance can be realized quickly for cameras with frame frequency of tens of frames/second or hundreds of frames/second, thereby greatly improving the working efficiency.
In the general white balance method, when the gain is adjusted, a large step size is set to ensure the convergence speed, so that the convergence cannot be achieved. The method for directly calculating the gain can realize that the step length of the adjacent two times of gain adjustment is very small, and the accuracy of the white balance method is ensured.
Drawings
FIG. 1 is a schematic flow chart of the present invention;
FIG. 2 is a linear relationship between Cb and gain α;
fig. 3 is a linear relationship between Cr and gain γ.
Detailed Description
The invention provides a method for quickly and efficiently realizing automatic white balance of a color camera by directly calculating gain, which comprises the following specific implementation steps:
【1】 Obtaining a relational expression of a current gain R component gain gamma and a target gain R component gain gamma 'and a relational expression of a current gain B component gain alpha and a target gain B component gain alpha'; the specific implementation steps of the step are as follows:
determining a formula for converting an RGB space into a YCbCr space;
Y=a*γ*R+b*G+c*α*B (1)
Cb=α*B-Y=-a*γ*R-b*G+(1-c)*α*B (2)
Cr=γ*R-Y=(1-a)*γ*R-b*G-c*α*B (3)
wherein, Y is the brightness component of the pixel point in YCbCr space; cb is a blue offset component of the pixel point in the YCbCr space; cr is a red offset component of the pixel point in a YCbCr space; r is a red component of the pixel point in the RGB space, G is a green component of the pixel point in the RGB space, B is a blue component of the pixel point in the RGB space, a is a coefficient of the R component in the space conversion formula, B is a coefficient of the G component in the space conversion formula, c is a coefficient of the B component in the space conversion formula, gamma is a gain of the R component in the automatic white balance, and alpha is a gain of the B component in the automatic white balance.
As can be seen from equations (1), (2) and (3), α is a constant when γ is gain-adjusted; when the gain adjustment is performed on α, γ is taken as a constant. Thus, γ is linearly related to Cr, and α is linearly related to Cb, and specific linear relationships are shown in fig. 2 and 3.
[ 1.2 ] according to the formulas (1), (2) and (3):
Y′=a*γ′*R+b*G+c*α′*B (4)
Cb′=α′*B-Y′=-a*γ′*R-b*G+(1-c)*α′*B (5)
Cr′=γ′*R-Y′=(1-a)*γ′*R-b*G-c*α′*B (6)
wherein, Cr' is a red offset component, i.e. a target value, when the automatic white balance method converges, and is a constant; cb' is a constant, which is the blue shift component when the automatic white balance method converges, i.e., the target value; γ 'is the gain of the R component at the time of convergence of the automatic white balance method, and α' is the gain of the B component at the time of convergence of the automatic white balance method.
Can be obtained by the arrangement of the formula (5) and the formula (6)
It can be seen that the target gains γ 'and α' can be calculated from the current gains γ and α.
【2】 Setting a white point number threshold value w, detecting each pixel of the current frame image N, judging whether the pixel is a white point, counting the number w 'of the detected white points of the current frame image N, comparing the detected white point number w' of the current frame image N with the white point number threshold value w, if w 'is more than or equal to w, performing the step (3), and if w' is less than w, performing the step (6); (ii) a 1/500 for the total number of w detector pixels in this embodiment. (ii) a
The judgment condition that any pixel in the current frame image N is a white point is as follows: y is more than or equal to A, | Cb | is less than or equal to B, | Cr | is less than or equal to C; wherein, A is 2048, B is 10 and C is 20. Since the number of quantization bits of a camera implementing this method is 12 bits, the range of the gradation value is 0 to 4095, and the value of a is set to half of the range of the gradation value in this method, a is set to 2048.
【3】 Estimating the color temperature of the current frame image N, and judging whether color cast occurs or not;
calculating the average value of all white points of the current frame image NAnd
if it is notIf M is set to 9, judging that the image has color cast, and B or R components need to be subjected to gain adjustment, and entering step 4;
if it is notJudging that the image has no color cast and entering step 6;
【4】 When in useCalculating a target gain R component gain gamma' according to a formula (1); when in useCalculating a target gain B component gain alpha' according to a formula (2);
【5】 And (4) carrying out white balance adjustment on the current frame image through the target gain R component gain gamma 'or the target gain B component gain alpha' obtained in the step (4).
【6】 After waiting for the 1 frame image transmission, the steps [ 2 ] to [ 5 ] are repeated from the N +2 frame image. The reason for this is that after new gains γ 'and α' are calculated from the nth frame image, if the frame rate is fast enough, the N +1 th frame image is already output and the new gain does not work. The new gain will be applied to the N +2 th frame image. So in order to ensure the correctness of the automatic white balance, the method is adopted.
Because many parameters of w, A, B, C and the like are set by self, if the set parameters are not proper, the automatic white balance can also be incapable of converging, and the adjusting times T of the automatic white balance can be set. If the threshold value is exceeded, the automatic white balance is temporarily stopped, and after a period of time, the gain is restored to the default value, and the calculation is restarted.
Claims (2)
1. A method for realizing automatic white balance of a color camera is characterized by comprising the following steps:
【1】 Acquiring a relational expression of a current gain R component gain gamma and a target gain R component gain gamma 'and a relational expression of a current gain B component gain alpha and a target gain B component gain alpha' according to the space conversion relation between RGB and YCbCr;
the concrete formula is as follows:
cb is a blue offset component of a pixel point in a YCbCr space; cr is a red offset component of the pixel point in a YCbCr space; g is the green component of the pixel point in the RGB space, B is the blue component of the pixel point in the RGB space, a is the coefficient of the R component in the space conversion formula, B is the coefficient of the G component in the space conversion formula; cr' is a red offset component when the automatic white balance method converges, namely a target value, and is a constant; cb' is a constant, which is the blue shift component when the automatic white balance method converges, i.e., the target value;
【2】 Setting a white point number threshold value w, detecting each pixel of the current frame image N, judging whether the pixel is a white point, counting the number w 'of the detected white points of the current frame image N, comparing the detected white point number w' of the current frame image N with the white point number threshold value w, if w 'is more than or equal to w, performing the step (3), and if w' is less than w, performing the step (6);
【3】 Estimating the color temperature of the current frame image N, and judging whether color cast occurs or not;
the judgment condition that any pixel in the current frame image N is a white point is as follows: y is more than or equal to A, | Cb | is less than or equal to B, | Cr | is less than or equal to C; wherein, A is 2048, B is 10, and C is 20;
calculating the average value of all white points of the current frame image NAnd
if it is notIf M is set to be 9, judging that the image has color cast, and adjusting the gain of the component B or R, and entering the step (4);
if it is notJudging that the image has no color cast, and entering the step (6);
【4】 When in useCalculating a target gain R component gain gamma' according to a formula (1); when in useCalculating a target gain B component gain alpha' according to a formula (2);
【5】 Performing white balance adjustment on the current frame image through the target gain R component gain gamma 'or the target gain B component gain alpha' obtained in the step (4);
【6】 After waiting for the 1 frame image transmission, the steps [ 2 ] to [ 5 ] are repeated from the N +2 frame image.
2. The method for realizing automatic white balance of a color camera according to claim 1, wherein: w is 1/500 of the total number of detector pixels.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811365142.2A CN109246406B (en) | 2018-11-16 | 2018-11-16 | Method for realizing automatic white balance of color camera |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811365142.2A CN109246406B (en) | 2018-11-16 | 2018-11-16 | Method for realizing automatic white balance of color camera |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109246406A CN109246406A (en) | 2019-01-18 |
CN109246406B true CN109246406B (en) | 2019-12-31 |
Family
ID=65075567
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811365142.2A Active CN109246406B (en) | 2018-11-16 | 2018-11-16 | Method for realizing automatic white balance of color camera |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109246406B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113674258B (en) * | 2021-08-26 | 2022-09-23 | 展讯通信(上海)有限公司 | Image processing method and related equipment |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101227623B (en) * | 2008-01-31 | 2012-07-04 | 炬力集成电路设计有限公司 | White balance adjustment method, system and camera |
US8493482B2 (en) * | 2010-08-18 | 2013-07-23 | Apple Inc. | Dual image sensor image processing system and method |
CN104618703B (en) * | 2015-02-09 | 2016-08-24 | 傅邓文 | A kind of white balance adjustment method |
CN107027017A (en) * | 2017-04-25 | 2017-08-08 | 建荣半导体(深圳)有限公司 | A kind of method of adjustment, device, picture processing chip and the storage device of image white balance |
-
2018
- 2018-11-16 CN CN201811365142.2A patent/CN109246406B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN109246406A (en) | 2019-01-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11849224B2 (en) | Global tone mapping | |
TWI389559B (en) | Foreground image separation method | |
EP3648459B1 (en) | White balance adjustment method and apparatus, camera and medium | |
US7949185B2 (en) | Method of performing robust auto white balance | |
CN103065334B (en) | A kind of color cast detection based on hsv color space, bearing calibration and device | |
CN102271260B (en) | Method for adjusting white balance | |
CN112118388B (en) | Image processing method, image processing device, computer equipment and storage medium | |
CN109785240B (en) | Low-illumination image enhancement method and device and image processing equipment | |
TWI549511B (en) | Image sensing apparatus and color-correction matrix correcting method and look-up table establishing method | |
CN105282529B (en) | A kind of digital wide dynamic approach and device based on RAW spaces | |
JP2000171304A (en) | Detecting method of color illumination color temperature and device therefor | |
WO2019061766A1 (en) | Image processing method and device | |
US20100321523A1 (en) | Method, apparatus, and system for selecting pixels for automatic white balance processing | |
WO2020007166A1 (en) | Video signal processing method and apparatus | |
WO2019104047A1 (en) | Global tone mapping | |
JP2019186916A (en) | Image processing | |
KR101774735B1 (en) | Method for improvement of shadow area around car number plate and car number recognition | |
US20190052855A1 (en) | System and method for detecting light sources in a multi-illuminated environment using a composite rgb-ir sensor | |
KR20100009035A (en) | Apparatus and method for controlling gain of color signal | |
CN109246406B (en) | Method for realizing automatic white balance of color camera | |
CN208353496U (en) | A kind of white balance correction device based on RGB-IR image data | |
KR20180040423A (en) | system for detecting space correlated color temperature using image sensor AWB | |
WO2022032666A1 (en) | Image processing method and related apparatus | |
KR101131109B1 (en) | Auto white balance setting method by white detection considering sensor characteristic | |
TWI556643B (en) | Image adjustment method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |