Image automatic white balance method, device, medium and equipment

CN116320348BActive Publication Date: 2026-10-30SHANGHAI INTEGRATED CIRCUIT RESEARCH & DEVELOPMENT CENTER CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310092000.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-30
Publication Date
2026-10-30
Estimated Expiration
2043-01-30

AI Technical Summary

Technical Problem

可见,现有色温估计算法的进行色温标定过程中得出的结果为色温参考点与对应增益的关系,所以就无法排除实际色温不存在于提前标定的参考点的情况,也会存在统计产生的点与两个不同标定参考点距离相等而无法选定增益值的情况,这样就会存在色温估计精度不足,继而导致白平衡校正效果不佳,另外,在硬件实现时上述方法存在计算复杂度较大而导致对组合逻辑消耗较大的问题

Benefits of technology

[0006]本发明提供的图像自动白平衡方法的有益效果在于:本实施例不再需要通过复杂的计算来判断有效像素点,该发明在硬件设计时能够实现统计待处理图像的白色像素点的G/B比值和G/R比值,就可以确定像素点所在子区域,所需参数相对更少,硬件实现时通过过简单移位即可完成,因此消耗的组合逻辑资源更少。另外,在色温标定阶段因选择足够数量的色温下的参考原始图像,样本数量充分,所以最终得到的白平衡增益矩阵的准确度越高,从而白平衡校正效果更佳。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116320348B_ABST
    Figure CN116320348B_ABST
Patent Text Reader

Abstract

The application discloses an image automatic white balance method, device, medium and equipment, the method comprises the following steps: obtaining L frames of reference original images obtained by shooting a white object under different color temperatures; counting the G / B ratio and G / R ratio of white pixel points of each frame of reference original image; then determining the distribution state of the white pixel points in a set coordinate system; dividing the set coordinate system into N*N sub-regions to generate an N*N white balance gain weight matrix; counting the G / B ratio and G / R ratio of white pixel points of a to-be-processed image to obtain the distribution state of the white pixel points in each sub-region of the set coordinate system and generate an N*N distribution matrix; obtaining the white balance gain matrix of the to-be-processed image according to the distribution matrix and the white balance gain weight matrix; updating the white balance adjustment parameter value and performing white balance processing on the to-be-processed image. The method is used to improve the automatic white balance algorithm, thereby improving the white balance correction effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to an automatic white balance method, apparatus, medium, and device for images. Background Technology

[0002] Currently, to ensure that the colors of acquired images remain true to life without distortion, the Automatic White Balance (AWB) module is a crucial and indispensable component of the Image Signal Processor (ISP). Its correction can affect the processing performance of subsequent image processing modules, thus playing a significant role in the overall image processing result. White refers to the visual perception formed when the proportions of red, green, and blue light reflected into the human eye are equal and possess a certain brightness. The purpose of AWB is to reproduce white objects captured by the image sensor as white, regardless of the light source. The current mainstream AWB processing can generally be divided into two parts: color temperature estimation of the shooting light source and color correction of the actual image. One existing color temperature estimation method involves selecting four different color temperatures during the color temperature calibration process, photographing white objects at each color temperature, calculating their G / B and G / R values, and fitting these values ​​into a 1024×G / B–1024×G / R coordinate system to obtain... Figure 1 The color temperature calibration curve is shown. Based on this fitting result, the range of white pixels is defined, as shown below. Figure 2 As shown, pixels within the range of 1024×G / B and 1024×G / R results are treated as white pixels and included in the statistical range. The G / B and G / R values ​​are obtained by summing the R, G, and B components of the white pixels within the statistical range to estimate the current color temperature. Finally, the gain corresponding to the color temperature, stored in a register beforehand, is used as the current white balance correction gain for white balance processing of the image. It is evident that the existing color temperature estimation algorithm obtains a relationship between a color temperature reference point and its corresponding gain during color temperature calibration. Therefore, it cannot rule out situations where the actual color temperature does not exist at the pre-calibrated reference point, and it may also encounter situations where the statistically generated point is equidistant from two different calibration reference points, making it impossible to select a gain value. This results in insufficient color temperature estimation accuracy, leading to poor white balance correction. Furthermore, in hardware implementation, the above method suffers from high computational complexity, resulting in significant consumption of combinational logic.

[0003] Therefore, how to improve the poor white balance correction effect caused by insufficient color temperature estimation accuracy has become an urgent problem to be solved in the industry. Summary of the Invention

[0004] This invention provides an automatic white balance method, apparatus, medium, and device for improving the automatic white balance algorithm, thereby enhancing the white balance correction effect.

[0005] In a first aspect, the present invention provides an automatic white balance method for images, the method comprising: acquiring a set of images of a white object taken at different color temperatures, the set of images including L frames of reference original images, where L is the total number of reference original images taken at different color temperatures; calculating the G / B ratio and G / R ratio of white pixels in each frame of the reference original images; determining the distribution state of white pixels in a set coordinate system based on the G / B ratio and G / R ratio of the white pixels; dividing the set coordinate system into N×N sub-regions, calculating the distribution state of white pixels in each sub-region and generating an N×N white balance gain weight matrix; calculating the G / B ratio and G / R ratio of white pixels in the image to be processed, the distribution state of white pixels in each sub-region in the set coordinate system, and generating a distribution matrix; obtaining an N×N white balance gain matrix of the image to be processed based on the distribution matrix and the white balance gain weight matrix; updating white balance adjustment parameter values ​​based on the white balance gain matrix, and performing white balance processing on the image to be processed using the updated white balance adjustment parameter values.

[0006] The advantages of the automatic white balance method provided by this invention are as follows: This embodiment eliminates the need for complex calculations to determine effective pixels. In hardware design, the invention can determine the sub-region of a pixel by statistically analyzing the G / B and G / R ratios of white pixels in the image to be processed. This requires fewer parameters and can be achieved through simple bit shifting in hardware implementation, thus consuming less combinational logic resources. Furthermore, in the color temperature calibration stage, a sufficient number of reference original images at different color temperatures are selected, resulting in a sufficient sample size and higher accuracy of the final white balance gain matrix, leading to better white balance correction.

[0007] In one possible embodiment, determining the distribution state of white pixels in a set coordinate system based on the G / B ratio and G / R ratio of the white pixels includes: performing a point-to-point processing on the G / B ratio and G / R ratio of the white pixels to multiply them by a factor of m, obtaining m×G / B and m×G / R, where m is 2. n n and m are both positive integers; based on m×G / B and m×G / R, determine the distribution of white pixels in the m×G / B / m×G / R coordinate system.

[0008] In another possible embodiment, dividing the set coordinate system into N×N sub-regions includes: plotting the fitting points in the m×G / B / m×G / R coordinate system according to m×G / B and m×G / R; dividing the m×G / B / m×G / R coordinate system into N×N sub-regions, wherein the size of each sub-region is determined by dividing the maximum value of the x and y coordinates of the fitting points by N, where N is 2. p p is a positive integer greater than or equal to 3. In this embodiment, fixed-point conversion involves first scaling up by a certain factor and then scaling down accordingly, which avoids floating-point operations in the AWB algorithm module.

[0009] In other possible embodiments, obtaining the white balance gain matrix of the image to be processed based on the distribution matrix and the white balance gain weight matrix includes: when the elements in the distribution matrix are greater than a set threshold, obtaining the white balance gain matrix of the image to be processed based on the distribution matrix and the white balance gain weight matrix, wherein the white balance gain matrix includes an R-channel white balance gain matrix and a B-channel white balance gain matrix.

[0010] Secondly, embodiments of this application also provide an automatic white balance device for images, which includes modules / units for performing any of the possible design methods described in the first aspect. These modules / units can be implemented in hardware or by hardware executing corresponding software.

[0011] Thirdly, embodiments of this application provide an electronic device, including a processor and a memory. The memory stores one or more programs; when the processor executes the one or more programs stored in the memory, the electronic device is able to implement any of the possible design methods described in the first aspect.

[0012] Fourthly, this application also provides a readable storage medium, the computer-readable storage medium including a program that, when run on an electronic device, causes the electronic device to perform any of the possible designs of the first aspect described above.

[0013] Fifthly, embodiments of this application also provide a method comprising a program product, which, when running on a terminal, causes the electronic device to perform any of the possible designs described in the first aspect.

[0014] For the beneficial effects of the second to fifth aspects mentioned above, please refer to the description in the first aspect mentioned above. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 A schematic diagram of a color temperature calibration curve provided for existing technology;

[0017] Figure 2 A schematic diagram illustrating the delineation of the area of ​​white pixels provided by existing technology;

[0018] Figure 3 A schematic diagram of a communication system architecture provided for existing technologies;

[0019] Figure 4 This is a schematic diagram of an automatic white balance method for images provided in this embodiment;

[0020] Figure 5 This is a schematic diagram of a coordinate system for dividing sub-regions, provided in an embodiment of the present invention.

[0021] Figure 6 This is a schematic diagram of an application scenario provided by an embodiment of the present invention;

[0022] Figure 7 This is a schematic diagram of an image processing device provided in an embodiment of the present invention;

[0023] Figure 8 A schematic diagram illustrating the calculation process of a white balance gain matrix provided in an embodiment of the present invention;

[0024] Figure 9 This is a schematic diagram of an automatic white balance device for images provided in an embodiment of the present invention;

[0025] Figure 10 This is a schematic diagram of a terminal device structure provided in an embodiment of the present invention. Detailed Implementation

[0026] In the description of the embodiments of this application, the terminology used in the following embodiments is for the purpose of describing specific embodiments only and is not intended to be a limitation of this application. As used in the specification and appended claims of this application, the singular expressions "a," "the," "the," "the," and "this" are intended to also include expressions such as "one or more," unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of this application, "at least one" and "one or more" refer to one or more (including two). The term "and / or" is used to describe the relationship between related objects, indicating that three relationships can exist; for example, A and / or B can indicate: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.

[0027] References to "one embodiment" or "some embodiments" in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized. The term "connection" includes direct connections and indirect connections, unless otherwise stated. "First" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated.

[0028] In the embodiments of this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.

[0029] The automatic white balance method for images provided in this application embodiment can be applied to, for example... Figure 3 The communication system architecture shown includes a server 100 and a terminal device 200.

[0030] In one possible design, server 100 is used to acquire L frames of reference original images of white objects taken at different color temperatures from terminal device 200; calculate the G / B ratio and G / R ratio of white pixels in each frame of the reference original image; determine the distribution state of white pixels in a set coordinate system based on the G / B ratio and G / R ratio of the white pixels; divide the set coordinate system into N×N sub-regions, calculate the distribution state of white pixels in each sub-region, and generate an N×N white balance gain weight matrix; the weight matrix includes a weight value corresponding to each sub-region, and the weight value is used to indicate the distribution state of the G / B ratio and G / R ratio of white pixels at different color temperatures. It should be understood that the above weight matrix calculation process can also be performed by terminal device 200. Here, the G / B ratio refers to the ratio between the G component and the B component of a pixel, and the G / R ratio refers to the ratio between the G component and the R component of a pixel.

[0031] Terminal device 200 obtains the aforementioned weight matrix from server 100. In the actual image processing process, it can statistically analyze the G / B ratio and G / R ratio of white pixels in the image to be processed, determine the distribution of white pixels in each sub-region under a set coordinate system, and generate a distribution matrix. Based on the distribution matrix and the white balance gain weight matrix, it obtains the N×N white balance gain matrix of the image to be processed. It updates the white balance adjustment parameter values ​​based on the white balance gain matrix and uses the updated white balance adjustment parameter values ​​to perform white balance processing on the image to be processed.

[0032] The server 100 and the terminal device 200 can be connected via a wireless network or a wired network. The terminal device 200 can be a terminal device equipped with an image sensor, such as a smartphone or tablet. The server 100 can be a single server, or a server cluster or cloud computing center composed of several servers.

[0033] based on Figure 1 The application scenario diagram shown illustrates the flowchart of an automatic white balance method for images provided in this application embodiment. Figure 4 As shown, the method includes the following steps:

[0034] S401, acquire a set of images of a white object taken at different color temperatures, the set of images including L reference original images, where L is the total number of reference original images taken at different color temperatures.

[0035] In this step, commonly used standard light sources such as D65 (6500K), CWF (4150K), TL84 (4000K), U30 (3000K), A (2856K), and F (2700K) can be selected in the color temperature chamber. Then, images of white objects taken at different color temperatures are collected. Besides the common light source color temperatures, the color temperature can be selected based on the actual conditions of the color temperature chamber. During the color temperature calibration stage, a sufficient number of reference original images at different color temperatures can be selected as needed. The larger the value of L, the more sufficient the sample size, resulting in a higher accuracy of the final white balance gain matrix and thus a better white balance correction effect. Furthermore, the number of reference original images collected at different color temperatures can be consistent, which helps improve the uniformity of the white balance gain matrix, thereby improving the white balance correction effect.

[0036] S402, Calculate the G / B ratio and G / R ratio of the white pixels in each frame of the reference original image.

[0037] S403, based on the G / B ratio and G / R ratio of the white pixels, determine the distribution state of the white pixels in the set coordinate system, divide the set coordinate system into N×N sub-regions, statistically analyze the distribution state of the white pixels in each sub-region, and generate an N×N white balance gain weight matrix.

[0038] The N×N weight matrix includes weight values ​​for each sub-region, which are used to indicate the distribution of G / B and G / R values ​​of white pixels at different color temperatures.

[0039] In this S403, the G / B ratio and G / R ratio of the white pixel can first be fixed-point multiplied by m to obtain m×G / B and m×G / R, where m is 2. n Where n and m are both positive integers; the distribution of white pixels in the m×G / B / m×G / R coordinate system is determined based on m×G / B and m×G / R. Then, the fitted points are obtained by plotting in the m×G / B / m×G / R coordinate system based on m×G / B and m×G / R; the m×G / B / m×G / R coordinate system is divided into N×N sub-regions, where the size of each sub-region is determined by dividing the maximum value of the horizontal and vertical coordinates of the fitted points by N.

[0040] S404: Calculate the G / B ratio and G / R ratio of white pixels in the image to be processed, obtain the distribution status of white pixels in each sub-region under the set coordinate system, and generate a distribution matrix.

[0041] S405, Based on the distribution matrix and the white balance gain weight matrix, obtain the N×N white balance gain matrix of the image to be processed.

[0042] In S405, when the elements in the distribution matrix are greater than a set threshold, the white balance gain matrix of the image to be processed is obtained according to the distribution matrix and the white balance gain weight matrix. The white balance gain matrix includes the R channel white balance gain matrix and the B channel white balance gain matrix.

[0043] S406, update the white balance adjustment parameter value according to the white balance gain matrix, and use the updated white balance adjustment parameter value to perform white balance processing on the image to be processed.

[0044] In other words, the above-mentioned automatic white balance method for images includes two stages. The first stage is to calculate the white balance gain weight matrix during the color temperature calibration stage. The second stage is to determine the white balance gain based on the distribution matrix and the white balance gain weight matrix, and then perform white balance processing on the image to be processed.

[0045] In the first stage, this invention is based on the theoretical foundation that G / B and G / R values ​​are relatively fixed under the same color temperature. First, the image sensor of the terminal device is configured to ensure that the white balance enable signal is turned off, preventing parameter calculations in the white balance algorithm from affecting the original image data (RAW). Then, different color temperatures are set in the color chamber (a significantly different color temperature value can be selected based on actual conditions), and white objects are photographed at different color temperatures, resulting in L frames of reference original images. The G / B and G / R ratios of white pixels in each frame of the reference original image are then statistically analyzed, and plotted in a set coordinate system to obtain fitting points. This coordinate system is divided into N×N sub-regions, and the distribution of white pixels in these N×N regions is statistically analyzed to generate an N×N white balance gain weight matrix. For example, setting the coordinate system as 1024×G / B-1024×G / R, firstly, the distribution of white pixels in each frame of the original reference image is statistically analyzed using 1024×G / B and 1024×G / R coordinates. Then, the fitted points are obtained by plotting the data in the 1024×G / B-1024×G / R coordinate system. Finally, this coordinate system is divided into 32×32 sub-regions, such as... Figure 5 As shown. Finally, a 32×32 white balance gain weight matrix (rbgain_matrix) is generated based on the statistical distribution of white pixels in the 32×32 regions. This white balance gain weight matrix represents the distribution of the G / B and G / R values ​​of white pixels at different color temperatures. In practical applications, a relatively accurate white balance gain matrix can be obtained by statistically analyzing the distribution matrix of each pixel in the original image in the 1024×G / B and 1024×G / R coordinate systems, along with the aforementioned white balance gain weight matrix. The white balance adjustment parameter values ​​are then updated based on this white balance gain matrix. Using the updated white balance adjustment parameter values ​​for white balance processing of the image to be processed yields a more ideal white balance processing effect.

[0046] It should be understood that this embodiment is not limited to the 1024×G / B-1024×G / R coordinate system; other coordinate systems are also acceptable. This embodiment primarily employs a fixed-point conversion method to avoid floating-point operations in the AWB algorithm module, i.e., first scaling up by a certain factor and then scaling down accordingly. In actual operation, the scaling factor does not necessarily need to be 1024, but should be limited to 2. n Both n and m are positive integers because in digital circuits, the multiplier is 2. n This can be achieved directly by expanding and left-shifting by n bits. This embodiment selects 2 bits based on the impact of the number of data bits on circuit timing in practical applications. 10 Furthermore, this embodiment also constrains the size of the white balance gain weight matrix, limiting it to N×N (equal rows and columns). The constraint on N includes N being 2... p p is a positive integer greater than or equal to 3, so N is greater than or equal to 8, and 8≤N≤Nmax. Nmax is determined by L, and the approximate range of Nmax is 2×(Nmax+2×(Nmax-1)). <L。

[0047] To elaborate on the second phase, such as... Figure 6 As shown, this implementation inputs the original data of the image to be processed into the color temperature estimation module. Then, the ratio calculation module calculates the G / B ratio and G / R ratio of a single pixel. The distribution matrix calculation module then statistically analyzes the distribution of each pixel in each region of the set coordinate system, obtaining the distribution matrix of the image to be processed. Finally, the white balance gain calculation module uses the distribution matrix and the pre-calculated white balance gain weight matrix to calculate the white balance gain matrix, which includes the R-channel white balance gain matrix and the B-channel white balance gain matrix. Finally, the white balance adjustment parameter value update module updates the white balance adjustment parameter values ​​using the white balance gain matrix, and then uses the updated white balance adjustment parameter values ​​to perform white balance processing on the image to be processed. In actual image processing, each value in the distribution matrix of the image to be processed represents the number of pixels that fall into the corresponding sub-region, that is, the distribution of pixels in the set coordinate system. The N×N white balance gain weight matrix is ​​obtained by testing a sufficient number of reference original images under ideal experimental conditions (specifying multiple common color temperatures) based on their distribution in the set coordinate system. Each element represents the weight of the sub-region.

[0048] like Figure 7 As shown, taking m=1024 as an example, the specific calculation process of the distribution matrix in the image to be processed can include the following steps:

[0049] S701: First, determine whether the R component and B component of the white pixel in the image to be processed are zero. If they are zero, execute S707; otherwise, execute S702.

[0050] S702, if not zero, then calculate G / B_temp = 1024 × G / B and G / R_temp = 1024 × G / R.

[0051] S703, calculate Bgain_bin = G / B_temp / unit and Rgain_bin = G / R_temp / unit, where unit determines the size of the corresponding sub-region.

[0052] S704, determine the sub-region corresponding to the white pixel based on Bgain_bin and Rgain_bin.

[0053] S705: Determine whether the white pixel falls within the set threshold range. If it does, it is a valid white pixel, and S705 is executed. Otherwise, return to the next white pixel and execute S701.

[0054] S706, increment the coordinates of the white balance gain weight matrix of this sub-region by 1, and begin traversing the next white pixel.

[0055] S707, if it is zero, then set G / B_temp and G / R_temp to their default values, for example, the default value is 1024, then S703.

[0056] As can be seen, the present invention transforms the operation of determining whether each pixel is a valid statistical point through complex calculations into counting each pixel that reaches the threshold into a statistical point, and finally obtains the distribution matrix of the image to be processed.

[0057] like Figure 8 As shown, taking m=1024 as an example, the specific calculation process of the white balance gain matrix includes:

[0058] S801: After initialization, each element in the distribution matrix is ​​polled to determine its validity. If valid, S802 is executed; otherwise, the next element is traversed.

[0059] S802, if this element is valid, calculate the white balance gain matrix of the R channel and the white balance gain matrix of the B channel.

[0060] S803: Determine if the element in the R-channel white balance gain weight matrix and the B-channel white balance gain weight matrix is ​​zero. If it is zero, proceed to the next element. If it is not zero, execute S804.

[0061] S804, if not zero, sum the weights of the corresponding elements in the white balance gain weight matrix, the R gain matrix, and the B gain matrix, with the summed values ​​being weight_sum, rgain_sum, and bgain_sum. Then, iterate through each element in each row (col) and each column (row) of the matrix to obtain the three summed values ​​for each element.

[0062] S805, check if weight_sum, rgain_sum and bgain_sum are zero. If they are, execute S806; otherwise, execute S807.

[0063] S806: If any accumulated value is zero, the current frame color temperature estimation mode statistics will fail, and the gain will remain unchanged.

[0064] S807 indicates that the color temperature estimation mode statistics for the current image to be processed are invalid, and the gain remains unchanged at the current value; if weight_sum, rgain_sum and bgain_sum are not zero, then the current statistics are effective, and the following gain values ​​are updated to the current statistical results, where Rgain = rgain_sum / weight_sum, bgain = bgain_sum / weight_sum.

[0065] In summary, this embodiment eliminates the need for complex calculations to determine valid pixels. The invention, in its hardware design, can determine the sub-region of a pixel by statistically analyzing the G / B and G / R ratios of white pixels in the image to be processed. This requires fewer parameters and can be accomplished through simple bit shifting in hardware implementation, thus consuming less combinational logic resources. Furthermore, by selecting a sufficient number of reference original images at various color temperatures during the color temperature calibration stage, the sample size is ample, resulting in a higher accuracy of the final white balance gain matrix and thus a better white balance correction effect.

[0066] In some embodiments of this application, an automatic white balance device for images is disclosed, such as... Figure 9 As shown, this device is used to implement the methods described in the above method embodiments, and includes: an acquisition unit 901, a statistics unit 902, a generation unit 903, and a processing unit 904. Wherein:

[0067] The acquisition unit 901 is used to acquire a set of images of a white object taken at different color temperatures. The set of images includes L reference original images, where L is the total number of reference original images taken at different color temperatures.

[0068] The statistics unit 902 is used to count the G / B ratio and G / R ratio of white pixels in each frame of the reference original image; determine the distribution state of white pixels in a set coordinate system based on the G / B ratio and G / R ratio of white pixels; divide the set coordinate system into N×N sub-regions and count the distribution state of white pixels in each sub-region.

[0069] Generation unit 903 is used to generate an N×N white balance gain weight matrix.

[0070] The statistical unit 902 is also used to statistically analyze the G / B ratio and G / R ratio of white pixels in the image to be processed, so as to obtain the distribution status of white pixels in each sub-region under the set coordinate system.

[0071] The generation unit 903 is also used to generate a distribution matrix; and to obtain an N×N white balance gain matrix of the image to be processed based on the distribution matrix and the white balance gain weight matrix.

[0072] The processing unit 904 is used to update the white balance adjustment parameter value according to the white balance gain matrix, and to perform white balance processing on the image to be processed using the updated white balance adjustment parameter value.

[0073] All relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0074] In other embodiments of this application, an electronic device is disclosed, such as... Figure 10 As shown, the device may include: one or more processors 1001; a memory 1002; a display 1003; one or more application programs (not shown); and one or more programs 1004. These devices may be connected via one or more communication buses 1005. The one or more programs 1004 are stored in the memory 1002 and configured to be executed by the one or more processors 1001, and the one or more programs 1004 include instructions.

[0075] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0076] In the embodiments of this application, the functional units can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0077] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, essentially, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as flash memory, portable hard disk, read-only memory, random access memory, magnetic disk, or optical disk.

[0078] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.

Claims

1. An automatic white balance method for images, characterized in that, The method includes: Acquire a set of images of a white object taken at different color temperatures, the set of images including L reference original images, where L is the total number of reference original images taken at different color temperatures; Calculate the G / B ratio and G / R ratio of the white pixels in each frame of the reference original image; Based on the G / B ratio and G / R ratio of the white pixels, determine the distribution state of the white pixels in the set coordinate system; The set coordinate system is divided into N×N sub-regions, and the distribution of white pixels in each sub-region is statistically analyzed to generate an N×N white balance gain weight matrix. The G / B ratio and G / R ratio of white pixels in the image to be processed are statistically analyzed to obtain the distribution of white pixels in each sub-region under a set coordinate system, and a distribution matrix is ​​generated. The calculation process of the distribution matrix includes the following steps: S701, determine whether the R component and B component of the white pixel in the image to be processed are zero. If they are zero, execute S707; otherwise, execute S702. S702, calculate G / B_temp = 1024 × G / B and G / R_temp = 1024 × G / R; S703, calculate Bgain_bin = G / B_temp / unit and Rgain_bin = G / R_temp / unit, where unit determines the size of the corresponding sub-region; S704, determine the sub-region corresponding to the white pixel based on Bgain_bin and Rgain_bin; S705, determine whether the white pixel falls within the set threshold range. If it does, it is a valid white pixel and proceed to S706. Otherwise, return to the next white pixel and proceed to S701. S706, increment the coordinates of the white balance gain weight matrix of this sub-region by 1, and start traversing the next white pixel; S707, set G / B_temp and G / R_temp to their default values, then S703; Based on the distribution matrix and the white balance gain weight matrix, the N×N white balance gain matrix of the image to be processed is obtained; The white balance adjustment parameter values ​​are updated according to the white balance gain matrix, and the updated white balance adjustment parameter values ​​are used to perform white balance processing on the image to be processed.

2. The method according to claim 1, characterized in that, Based on the G / B ratio and G / R ratio of the white pixels, the distribution state of the white pixels in a set coordinate system is determined, including: The G / B ratio and G / R ratio of the white pixels are multiplied by a factor of m to obtain m×G / B and m×G / R, where m is 2. n Both n and m are positive integers; Based on m×G / B and m×G / R, determine the distribution of white pixels in the m×G / B / m×G / R coordinate system.

3. The method according to claim 2, characterized in that, The established coordinate system is divided into N×N sub-regions, including: Based on m×G / B and m×G / R, plot the fitting points in the m×G / Bm×G / R coordinate system; The m×G / Bm×G / R coordinate system is divided into N×N sub-regions, where the size of each sub-region is determined by dividing the maximum value of the x and y coordinates of the fitted points by N, where N is 2. p p is a positive integer greater than or equal to 3.

4. The method according to any one of claims 1 to 3, characterized in that, Based on the distribution matrix and the white balance gain weight matrix, the white balance gain matrix of the image to be processed is obtained, including: When the elements in the distribution matrix are greater than a set threshold, the white balance gain matrix of the image to be processed is obtained according to the distribution matrix and the white balance gain weight matrix. The white balance gain matrix includes the R-channel white balance gain matrix and the B-channel white balance gain matrix.

5. An automatic white balance device for images, used to implement the automatic white balance method for images as described in any one of claims 1 to 4, characterized in that, The device includes: The acquisition unit is used to acquire a set of images of a white object taken at different color temperatures. The set of images includes L reference original images, where L is the total number of reference original images taken at different color temperatures. The statistical unit is used to calculate the G / B ratio and G / R ratio of white pixels in each frame of the reference original image; determine the distribution of white pixels in a set coordinate system based on the G / B ratio and G / R ratio of the white pixels; divide the set coordinate system into N×N sub-regions and calculate the distribution of white pixels in each sub-region. The generation unit is used to generate an N×N white balance gain weight matrix; The statistical unit is also used to calculate the G / B ratio and G / R ratio of the white pixels in the image to be processed, so as to obtain the distribution status of the white pixels in each sub-region under the set coordinate system. The generation unit is further configured to generate a distribution matrix; and to obtain an N×N white balance gain matrix of the image to be processed based on the distribution matrix and the white balance gain weight matrix. The processing unit is used to update the white balance adjustment parameter value according to the white balance gain matrix, and to perform white balance processing on the image to be processed using the updated white balance adjustment parameter value.

6. The apparatus according to claim 5, characterized in that, The statistical unit determines the distribution of white pixels in a set coordinate system based on the G / B ratio and G / R ratio of the white pixels, specifically for: The G / B ratio and G / R ratio of the white pixels are multiplied by a factor of m to obtain m×G / B and m×G / R, where m is 2. n Both n and m are positive integers; Based on m×G / B and m×G / R, determine the distribution of white pixels in the m×G / B / m×G / R coordinate system.

7. The apparatus according to claim 5, characterized in that, The statistical unit divides the set coordinate system into N×N sub-regions, specifically for: Based on m×G / B and m×G / R, plot the fitting points in the m×G / Bm×G / R coordinate system; The m×G / Bm×G / R coordinate system is divided into N×N sub-regions, where the size of each sub-region is determined by dividing the maximum value of the x and y coordinates of the fitted points by N, where N is 2. p p is a positive integer greater than or equal to 3.

8. The apparatus according to any one of claims 5 to 7, characterized in that, The generation unit obtains the white balance gain matrix of the image to be processed based on the distribution matrix and the white balance gain weight matrix, specifically for: When the elements in the distribution matrix are greater than a set threshold, the white balance gain matrix of the image to be processed is obtained according to the distribution matrix and the white balance gain weight matrix. The white balance gain matrix includes the R-channel white balance gain matrix and the B-channel white balance gain matrix.

9. A computer-readable storage medium storing a program therein, characterized in that, When the program is executed by the processor, it implements the method of any one of claims 1 to 4.

10. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory stores a program that can run on the processor, and when the program is executed by the processor, causes the electronic device to perform the method of any one of claims 1 to 4.

Citation Information

Patent Citations

  • White balance correcting method and white balance correcting device

    CN103297789A