[go: up one dir, main page]

CN120343175A - Automatic white balance method and device based on color temperature estimation, electronic device and computer storage medium - Google Patents

Automatic white balance method and device based on color temperature estimation, electronic device and computer storage medium

Info

Publication number
CN120343175A
CN120343175A CN202510538198.7A CN202510538198A CN120343175A CN 120343175 A CN120343175 A CN 120343175A CN 202510538198 A CN202510538198 A CN 202510538198A CN 120343175 A CN120343175 A CN 120343175A
Authority
CN
China
Prior art keywords
color temperature
difference value
white balance
image
color
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.)
Pending
Application number
CN202510538198.7A
Other languages
Chinese (zh)
Inventor
彭怀宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Granfei Intelligent Technology Co ltd
Original Assignee
Granfei Intelligent Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Granfei Intelligent Technology Co ltd filed Critical Granfei Intelligent Technology Co ltd
Priority to CN202510538198.7A priority Critical patent/CN120343175A/en
Publication of CN120343175A publication Critical patent/CN120343175A/en
Pending legal-status Critical Current

Links

Landscapes

  • Processing Of Color Television Signals (AREA)
  • Color Television Image Signal Generators (AREA)

Abstract

本发明提供一种基于色温估计的自动白平衡方法及装置、电子设备和计算机存储介质,包括:获取色温曲线;对原始图像进行分块以得到多个图像块;计算图像块的色差值;利用色温曲线和图像块色差值,计算最终估计光源色温点,进而计算自动白平衡的像素增益;利用像素增益对原始图像进行自动白平衡校正。通过将原始图像分割为多个图像块,利用图像块的色差值与色温曲线计算估计光源色温点,使得估计得到的场景光源色温更准确,从而使得计算得到的像素增益更加精准,自动白平衡校正的效果更好;同时,该自动白平衡方法计算过程简单、资源消耗少、效率高,且具有更强的鲁棒性,适用于各类场景,解决了现有的白平衡处理效果欠佳,应用场景受限的问题。

The present invention provides an automatic white balance method and device based on color temperature estimation, an electronic device and a computer storage medium, including: obtaining a color temperature curve; dividing an original image into blocks to obtain a plurality of image blocks; calculating the color difference value of the image block; using the color temperature curve and the color difference value of the image block to calculate the final estimated light source color temperature point, and then calculating the pixel gain of the automatic white balance; using the pixel gain to perform automatic white balance correction on the original image. By dividing the original image into a plurality of image blocks, using the color difference value of the image block and the color temperature curve to calculate the estimated light source color temperature point, the estimated scene light source color temperature is made more accurate, thereby making the calculated pixel gain more accurate, and the effect of automatic white balance correction is better; at the same time, the automatic white balance method has a simple calculation process, low resource consumption, high efficiency, and stronger robustness, and is applicable to various scenes, solving the problem that the existing white balance processing effect is poor and the application scenes are limited.

Description

Automatic white balance method and device based on color temperature estimation, electronic equipment and computer storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to an automatic white balance method and apparatus based on color temperature estimation, an electronic device, and a computer storage medium.
Background
The human visual device has the characteristic of constant color, and is basically not influenced by the change of the light source when observing objects. But the image sensor may appear in different colors on different lights, for example, blue on a clear sky and red on candles. In order to eliminate the color effect of the light source on the imaging of the image sensor, the color constancy of the human visual device is simulated to ensure that the white color seen in any scene is truly white, and white balance processing needs to be performed on the original image shot by the image sensor.
The existing white balance processing generally obtains the gain of each color channel of the original image by utilizing the distance from the color difference channel block to the color temperature curve, and further compensates the color deviation caused by the color temperature environment and the deviation of the inherent color channel gain of the shooting instrument by utilizing the gain, so that the finally displayed image can correctly reflect the true color of the object.
However, in the existing white balance processing method, when the distance from a color difference channel block to a color temperature curve is calculated, euclidean distance is adopted for calculation, and the difference between the color difference channel block and the color temperature curve cannot be measured well by the Euclidean distance calculation method, meanwhile, in the existing white balance processing method, only the color difference channel block falling in a certain range from the color temperature curve participates in calculation, the influence of the color difference channel block with a far distance on color temperature estimation is ignored, the number of effective color difference channel blocks in practical application is small, the coverage scene is insufficient, in addition, the prior relation between illumination intensity and a light source is not considered in the existing white balance processing method, and the color difference channel block is calculated according to a unified standard under different illumination intensities. These problems lead to poor white balance processing effect and limited application scenes.
Disclosure of Invention
The invention aims to provide an automatic white balance method and device based on color temperature estimation, electronic equipment and a computer storage medium, so as to solve the problems of poor white balance processing effect and limited application scene in the prior art.
In order to solve the above technical problems, the present invention provides an automatic white balance method based on color temperature estimation, comprising:
Acquiring a color temperature curve;
Partitioning an original image to obtain a plurality of image blocks;
calculating a color difference value of each image block;
calculating to obtain a final estimated light source color temperature point by utilizing the color temperature curve and the color difference value of the image block;
calculating the pixel gain of automatic white balance according to the color difference value of the final estimated light source color temperature point and the image block;
And compensating the original image by using the calculated pixel gain to obtain an image after automatic white balance correction.
Optionally, in the automatic white balance method based on color temperature estimation, the method for acquiring a color temperature curve includes:
shooting color cards under different color temperature light sources respectively to obtain color temperature images with different color temperatures;
Calculating an R/G color difference value and a B/G color difference value of each color temperature image;
And performing curve fitting by taking the R/G color difference value and the B/G color difference value of each color temperature image as the horizontal coordinate and the vertical coordinate of the curve to obtain a color temperature curve.
Optionally, in the automatic white balance method based on color temperature estimation, the method for calculating the R/G color difference value and the B/G color difference value of each color temperature image includes:
shading correction is carried out on the color temperature image;
acquiring the average value of an R channel, a B channel and a G channel of the corrected color temperature image in a preset area;
And calculating an R/G color difference value and a B/G color difference value of each color temperature image by using the R channel mean value, the B channel mean value and the G channel mean value of the color temperature image.
Optionally, in the automatic white balance method based on color temperature estimation, the method for calculating a color difference value of each image block includes:
calculating the average value of an R channel, a B channel and a G channel in each image block;
Calculating R/G color difference values and B/G color difference values of each image block by utilizing the R channel average value, the B channel average value and the G channel average value of the image block;
Setting a brightness threshold;
And screening the image blocks meeting the requirements according to the brightness threshold value, and obtaining the effective image block proportion.
Optionally, in the automatic white balance method based on color temperature estimation, the method for calculating to obtain the final estimated light source color temperature point by using the color temperature curve and the color difference value of each image block includes:
Traversing a color temperature curve according to a first step length, and calculating to obtain an initial estimated light source color temperature point by utilizing a color difference value of each image block;
traversing a color temperature curve according to a second step length within a preset range of the initial estimated light source color temperature point, and calculating to obtain a final estimated light source color temperature point by utilizing a color difference value of each image block;
Wherein the second step size is smaller than the first step size.
Optionally, in the automatic white balance method based on color temperature estimation, the method for calculating to obtain the initial estimated light source color temperature point by using the color difference value of each image block by traversing the color temperature curve according to the first step length includes:
acquiring a light source priori score list of different brightness levels;
traversing a color temperature curve according to a first step length, and calculating the sum of the color difference value of each image block and the distance of the color difference value of each color temperature point to obtain a first distance value;
acquiring prior scores corresponding to each color temperature point from a light source prior score list;
subtracting the prior score corresponding to the color temperature point corresponding to the first distance value from the first distance value to obtain a second distance value;
and taking the color temperature point corresponding to the smallest second distance value as an initial estimated light source color temperature point.
Optionally, in the automatic white balance method based on color temperature estimation, the method for calculating and obtaining the final estimated light source color temperature point by traversing a color temperature curve according to a second step length and using the color difference value of each image block in the preset range of the initial estimated light source color temperature point includes:
Traversing a color temperature curve according to a second step length in a preset range of initially estimated light source color temperature points, and calculating the sum of the color difference value of each image block and the distance of the color difference value of each color temperature point to obtain a third distance value;
acquiring prior scores corresponding to each color temperature point from a light source prior score list;
subtracting the prior score corresponding to the color temperature point corresponding to the third distance value from the third distance value to obtain a fourth distance value;
And taking the color temperature point corresponding to the smallest fourth distance value as the final estimated light source color temperature point.
Optionally, in the automatic white balance method based on color temperature estimation, the method for calculating the pixel gain of the automatic white balance according to the color difference value of the final estimated light source color temperature point and the image block includes:
taking an image block with the distance from the color difference value of the final estimated light source color temperature point within a preset distance as a reference image block;
Calculating the difference value between the color difference value of each reference image block and the color difference value of the final estimated light source color temperature point and the prior score to obtain a reference distance value;
if the reference distance value is smaller than the preset distance threshold value, the reference image block is used as an effective reference image block;
If the number of the effective reference image blocks is smaller than a preset number threshold, calculating the pixel gain of automatic white balance by utilizing the color difference value of the final estimated light source color temperature point;
If the number of the effective reference image blocks is greater than or equal to a preset number threshold, calculating the pixel gain of the automatic white balance by using the sum of R channels, the sum of B channels and the sum of G channels of all the effective reference image blocks.
To solve the above technical problem, the present invention further provides an automatic white balance device based on color temperature estimation, for implementing the automatic white balance method based on color temperature estimation as described in any one of the above, the automatic white balance device based on color temperature estimation includes:
the image acquisition module is used for acquiring an original image;
the color temperature curve acquisition module is used for acquiring a color temperature curve;
The image block color difference calculation module is used for dividing an original image into a plurality of image blocks and calculating a color difference value of each image block;
the pixel gain calculation module is used for calculating to obtain a final estimated light source color temperature point by utilizing the color temperature curve and the color difference value of each image block, and calculating the pixel gain of the automatic white balance according to the final estimated light source color temperature point and the color difference value of the image block;
The white balance compensation module is used for compensating the original image by using the calculated pixel gain so as to obtain an image after automatic white balance correction;
and the image output module is used for outputting the image after the automatic white balance correction.
In order to solve the technical problem, the invention also provides electronic equipment, which comprises a memory, a processor and an executable program stored on the memory and capable of being run by the processor, wherein the processor executes the automatic white balance method based on the color temperature estimation according to any one of the above when running the executable program.
In order to solve the technical problem, the invention also provides a computer storage medium which stores an executable program, and the executable program realizes the automatic white balance method based on the color temperature estimation according to any one of the above.
The invention provides an automatic white balance method and device based on color temperature estimation, electronic equipment and a computer storage medium, comprising the steps of obtaining a color temperature curve; the method comprises the steps of dividing an original image into a plurality of image blocks, calculating a color difference value of each image block, calculating a final estimated light source color temperature point by utilizing a color temperature curve and the color difference value of the image block, calculating pixel gains of automatic white balance according to the final estimated light source color temperature point and the color difference value of the image block, and compensating the original image by utilizing the calculated pixel gains to obtain an image after automatic white balance correction. The method has the advantages that the original image is divided into a plurality of image blocks, the color temperature points of the light source are calculated and estimated by utilizing the color difference values and the color temperature curves of the image blocks, so that the color temperature of the estimated scene light source is more accurate, the calculated pixel gain is more accurate, the automatic white balance correction effect is better, meanwhile, the automatic white balance method has simple calculation process, less resource consumption, high efficiency and stronger robustness, is suitable for various scenes, and solves the problems of poor white balance treatment effect and limited application scene in the prior art.
Drawings
Fig. 1 is a flowchart of an automatic white balance method based on color temperature estimation provided in the present embodiment;
fig. 2 is a schematic diagram of a color temperature curve provided in the present embodiment;
fig. 3 is a schematic diagram of image segmentation provided in the present embodiment;
Fig. 4 is a flowchart of a method provided in step S4 in this embodiment;
fig. 5 is a schematic diagram of a light source prior score list provided in the present embodiment;
fig. 6 is a schematic diagram of a color temperature curve corresponding to the initial estimated light source color temperature point obtaining process according to the present embodiment;
Fig. 7 is a schematic diagram of a color temperature curve corresponding to the process of obtaining the final estimated light source color temperature point according to the present embodiment;
fig. 8 is a schematic structural diagram of an automatic white balance device based on color temperature estimation according to the present embodiment.
Detailed Description
The method and apparatus for automatic white balance based on color temperature estimation, electronic device and computer storage medium according to the present invention are described in further detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the drawings are in a very simplified form and are all to a non-precise scale, merely for convenience and clarity in aiding in the description of embodiments of the invention. Furthermore, the structures shown in the drawings are often part of actual structures. In particular, the drawings are shown with different emphasis instead being placed upon illustrating the various embodiments.
It is noted that "first", "second", etc. in the description and claims of the present invention and the accompanying drawings are used to distinguish similar objects so as to describe embodiments of the present invention, and not to describe a specific order or sequence, it should be understood that the structures so used may be interchanged under appropriate circumstances. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, apparatus, article, or device that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or device.
The embodiment provides an automatic white balance method based on color temperature estimation, as shown in fig. 1, including:
s1, acquiring a color temperature curve;
s2, partitioning an original image to obtain a plurality of image blocks;
s3, calculating a color difference value of each image block;
S4, calculating to obtain a final estimated light source color temperature point by utilizing the color temperature curve and the color difference value of the image block;
S5, calculating pixel gain of automatic white balance according to the color difference value of the final estimated light source color temperature point and the image block;
and S6, compensating the original image by using the calculated pixel gain to obtain an image after automatic white balance correction.
According to the automatic white balance method and device based on color temperature estimation, the electronic equipment and the computer storage medium, the original image is divided into a plurality of image blocks, the color difference value and the color temperature curve of the image blocks are used for calculating and estimating the color temperature point of the light source, so that the estimated scene light source color temperature is more accurate, the calculated pixel gain is more accurate, the automatic white balance correction effect is better, meanwhile, the automatic white balance method is simple in calculation process, less in resource consumption, high in efficiency, stronger in robustness and suitable for various scenes, and the problems of poor existing white balance processing effect and limited application scenes are solved.
In practical applications, the order of implementation of the steps S1 and S2 and S3 may be reversed (steps S2 and S3 are first performed and step S1 is then performed), or the steps S1 and S2 or step S3 may be performed synchronously. The technical scheme after the step sequence adjustment without departing from the gist of the application also belongs to the protection scope of the application.
Specifically, in this embodiment, in step S1, the method for obtaining the color temperature curve includes:
s11, shooting color cards under different color temperature light sources respectively to obtain color temperature images with different color temperatures.
In practical application, gray plates or color cards can be respectively shot under different color temperature light sources of 7500K, 6500K, 5500K, 5000K, 4000K, 3200K, 2856K and the like so as to obtain color temperature images. Of course, in other embodiments, the required color temperature may be set to perform shooting according to actual needs, which is not limited by the present application.
S12, calculating an R/G color difference value and a B/G color difference value of each color temperature image.
In order to accurately obtain the color difference value of the color temperature image, in this embodiment, firstly, shading (lensshading) correction is performed on the color temperature image, so as to ensure that the pixel value of each pixel point is accurate.
Then, the average value of the R channel, the B channel and the G channel of the corrected color temperature image in the preset area is obtained. In practical application, an R channel, a B channel and a G channel of a central region pixel of a color temperature image or an R channel, a B channel and a G channel of a whole color temperature image pixel can be obtained, and an average value of the R channel, an average value of the B channel and an average value of the G channel can be obtained by carrying out average calculation on each channel value.
And finally, calculating an R/G color difference value and a B/G color difference value of the color temperature image by utilizing an R channel mean value, a B channel mean value and a G channel mean value of each color temperature image, wherein the ratio of the R channel mean value to the G channel mean value is taken as the R/G color difference value, and the ratio of the B channel mean value to the G channel mean value is taken as the B/G color difference value. The specific calculation method of the chromatic aberration is well known to those skilled in the art, and the present application will not be repeated.
And S13, performing curve fitting by taking the R/G color difference value and the B/G color difference value of each color temperature image as the horizontal coordinate and the vertical coordinate of the curve to obtain a color temperature curve.
In practical application, the fitting method can be realized by adopting the modes of segmentation broken line, quadratic curve fitting, cubic curve fitting and the like, and the application is not limited to the method.
In a specific embodiment, the color temperature curve obtained by using the piecewise polyline fitting method is shown in fig. 2. Each point on the color temperature curve represents the corresponding color difference value at different R/G color difference values and B/G color difference values.
Further, in the present embodiment, in step S2, the original image is segmented to obtain a plurality of image blocks. Specifically, as shown in fig. 3, the original image may be divided into m×n image blocks distributed in succession, where each image block includes a plurality of pixel points.
In practical application, the dividing mode and the number of the image blocks can be confirmed according to the size of the original image, the required white balance correction precision and the like. To simplify the calculation, the size of each image block should be uniform.
Further, in the present embodiment, in step S3, the method for calculating the color difference value of each image block includes:
S31, calculating the average value of the R channel, the B channel and the G channel in each image block.
Specifically, in this embodiment, an R channel, a B channel, and a G channel of each pixel in an image block are obtained, and an R channel mean value, a B channel mean value, and a G channel mean value of the image block are obtained by respectively performing average calculation on the R channel, the B channel, and the G channel of all pixels in the same image block.
S32, calculating R/G color difference values and B/G color difference values of each image block by using the R channel average value, the B channel average value and the G channel average value of the image block.
Specifically, in this embodiment, for each image block, the ratio of the average R channel value to the average G channel value is taken as the R/G color difference value of the image block, and the ratio of the average B channel value to the average G channel value is taken as the B/G color difference value of the image block.
In order to further improve the accuracy of the calculated gain in the automatic white balance process, in this embodiment, too bright image blocks and too dark image blocks are also removed, so that interference of bright pixel points and bad pixel points on white balance correction is avoided.
Specifically, in this embodiment, first, a luminance threshold is set, where the luminance threshold includes a luminance upper limit threshold and a luminance lower limit threshold, so as to respectively determine bright image blocks and dark image blocks, and then, according to the luminance threshold, image blocks meeting the requirements are screened, and an effective image block proportion is obtained.
In one embodiment, if the G-channel pixel value of the image block is smaller than the luminance lower threshold, it is determined that the image block is dark and needs to be removed, if the G-channel pixel value of the image block is larger than the luminance upper threshold, it is determined that the image block is bright and needs to be removed, and only if the G-channel pixel value of the image block is between the luminance upper threshold and the luminance lower threshold, it is determined that the image block is valid. And the effective image block ratio is the ratio of the number of effective image blocks to the total number of image blocks.
Of course, in other embodiments, corresponding brightness upper limit threshold and brightness lower limit threshold may be set for the R/G color difference value and the B/G color difference value according to actual requirements, so as to implement fine adjustment of different color difference channels and improve the effect of white balance correction.
Further, in this embodiment, as shown in fig. 4, in step S4, the method for calculating the final estimated light source color temperature point by using the color temperature curve and the color difference value of each image block includes:
S41, traversing a color temperature curve according to a first step length, and calculating to obtain an initial estimated light source color temperature point by using the color difference value of each image block.
Specifically, in this embodiment, step S41 specifically includes:
s411, acquiring a light source priori score list with different brightness levels.
In practical application, a light source priori score list can be constructed by utilizing scene brightness, color temperature and priori scores according to preset rules. In this embodiment, it is considered that in general, when the scene is very bright, a larger (more likely) value may be selected for the daytime light source, and thus, under these conditions, the indoor light source will be excluded, and under low and medium light conditions, the indoor light source will likely be favored. Meanwhile, the low-luminance scene is generally a low-color temperature light source such as an indoor light source, a night street lamp, etc., and the high-luminance scene is generally a high-color temperature light source such as a clear and cloudless noon. Therefore, according to the selection mode, a scene brightness-color temperature-priori score two-dimensional lookup table can be established, so that the priori score corresponding to the current candidate color temperature can be obtained from the light source priori score list according to brightness and candidate color temperature. The present embodiment provides an example of a list of light source prior scores, as shown in fig. 5.
S412, traversing the color temperature curve according to the first step length, and calculating the sum of the color difference value of each image block and the distance of the color difference value of the color temperature point at each color temperature point to obtain a first distance value.
Specifically, a manhattan distance (L1), a euclidean distance (L2), or a ratio distance may be used to calculate a distance between the R/G color difference value of each image block and the R/G color difference value of the color temperature point and a distance between the B/G color difference value of the image block and the B/G color difference value of the color temperature point, and then sum the two distances to obtain a first distance value S 1. The specific implementation of calculating the color difference distance is well known to those skilled in the art, and the present application will not be repeated here.
Preferably, after the first distance value is obtained, the effective image block proportion calculated in step S32 may be used to scale the first distance value, so as to further adjust the accuracy of the first distance value, so that the first distance value better matches the original image.
S413, obtaining the prior score corresponding to each color temperature point from the prior score list of the light source.
Specifically, the brightness estimation may be performed on the scene first, and then the scene brightness estimation value is brought into the light source prior score list to obtain the prior score thereof:
Firstly, shooting a gray plate under the preset brightness condition to obtain a reference image. Typically, the preset luminance condition is an environment with moderate luminance, such as 600lux lighting conditions. And shooting the gray plate under the condition, wherein the pixel value in the obtained reference image is the pixel value of the image graying. Meanwhile, exposure parameters, mainly including shutter time and gain, can also be obtained when the reference image is photographed. In practical application, the preset brightness conditions include, but are not limited to, illumination conditions, exposure parameters, etc., and the preset brightness conditions can be acquired and set offline in advance, and the acquisition and calculation can be directly invoked during the brightness estimation in this step.
Then, the pixel average value and the exposure parameter of the original image graying are obtained. The method for obtaining the pixel values of the graying of the original image is well known to those skilled in the art, and the present application will not be repeated. When the average value of the gray pixels of the original image is obtained, the gray pixel value of the central area of the original image can be selected, or the gray pixel value of the whole original image can be obtained by averaging the selected gray pixel values. The exposure parameter class of the original image is consistent with that of the reference image, and mainly comprises shutter time and gain.
Then, the ratio of the pixel average value of the original image to the reference image and the ratio of the exposure parameters are calculated. Specifically, the ratio of the pixel average values (noted yRatio), the ratio of the shutter time (noted shutterRatio), and the ratio of the gain (noted gainRatio) are included, with the relevant parameters of the reference image as a base (denominator).
And then calculating the scene brightness of the original image by using the ratio of the pixel average value and the ratio of the exposure parameters. Specifically, the scene brightness may be the product of the four values of the ratio of the pixel average values, the ratio of the shutter time, the ratio of the gain, and the ambient brightness of the reference image photographing.
Finally, the calculated scene brightness is brought into a light source priori score list to obtain a priori score thereof.
S414, subtracting the prior score corresponding to the color temperature point corresponding to the first distance value from the first distance value to obtain a second distance value S 2.
And S415, taking the color temperature point corresponding to the smallest second distance value as an initial estimated light source color temperature point.
In one embodiment, as shown in fig. 6, the initial estimated light source color temperature point is determined to be 4430K in step S41.
To this end, an initial estimated light source color temperature point is obtained by rough estimation. Since the step of the first step is larger in step S41, the calculation amount can be reduced, and the device efficiency can be improved while the device power consumption is reduced.
S42, traversing a color temperature curve according to a second step length within a preset range of the initial estimated light source color temperature point, and calculating to obtain a final estimated light source color temperature point by using a color difference value of each image block, wherein the second step length is smaller than the first step length.
Specifically, in this embodiment, similar to the implementation manner of step S41, the implementation manner of step S42 includes that firstly, traversing a color temperature curve according to a second step within a preset range of an initial estimated light source color temperature point, calculating a sum of a color difference value of each image block and a distance of the color temperature point color difference value at each color temperature point to obtain a third distance value S 3, then, obtaining a priori score corresponding to each color temperature point from a light source priori score list, then, subtracting the priori score corresponding to the color temperature point corresponding to the third distance value from the third distance value to obtain a fourth distance value S 4, and finally, taking a color temperature point corresponding to the smallest fourth distance value as a final estimated light source color temperature point.
In one embodiment, as shown in fig. 7, by performing fine search of the vicinity of the initial estimated light source color temperature point 4430K confirmed in step S41, an accurate final estimated light source color temperature point can be obtained.
In practical application, the preset range can be determined according to practical requirements, such as the accuracy requirement of white balance correction. Of course, the larger the preset range is, the more accurate the calculation result is, but the more the calculation amount is, the more the occupied resource consumption is, and the preset range needs to be comprehensively determined by balancing each factor in practical application.
To this end, the final estimated light source color temperature point is obtained by fine estimation. Since the step of the second step is smaller than the first step in step S42, the color temperature point of the light source can be determined more accurately. By performing rough estimation and then fine estimation, the calculation amount can be saved, and the efficiency of the device can be improved while the power consumption of the device is reduced.
In practical application, the rough search in step S41 may be performed in a uniform or non-uniform manner, and the fine search in step S42 may be performed in a uniform manner to ensure that the obtained final estimated light source color temperature point is accurate.
Further, in the present embodiment, step S5, the method for calculating the pixel gain of the automatic white balance according to the color difference value of the final estimated light source color temperature point and the image block includes:
s51, taking an image block with a distance from a color difference value of the finally estimated light source color temperature point within a preset distance as a reference image block.
Specifically, in practical application, the preset distance should be a small value, so that an image block with a relatively close distance from the color difference value of the finally estimated light source color temperature point is selected as the reference image block. The specific value of the preset distance can be reasonably set according to actual conditions, and the application is not limited to the specific value.
S52, calculating the difference value between the distance between the color difference value of each reference image block and the color difference value of the final estimated light source color temperature point and the prior score to obtain a reference distance value.
Specifically, in a specific embodiment, the distance between the R/G color difference value of the reference image block and the R/G color difference value of the final estimated light source color temperature point may be expressed as deltaR =rg/ct_rg1, where rg represents the R/G color difference value of the reference image block, ct_rg represents the R/G color difference value of the final estimated light source color temperature point, and similarly, the distance between the B/G color difference value of the reference image block and the B/G color difference value of the final estimated light source color temperature point may be expressed as deltaB =bg/ct_bg-1, where bg represents the B/G color difference value of the reference image block, ct_bg represents the B/G color difference value of the final estimated light source color temperature point, and the distance between the R/G color difference value and the B/G color difference value of the final estimated light source color temperature point is summed to obtain the distance between the color difference value of the reference image block and the final estimated light source color temperature point, i.e., delta 1=abs (deltaR) +abs (deltaB), where abs () represents the absolute value, and the distance represents the prior value of the final estimated light source color temperature point in the prior score list of 2.
In practical application, when calculating the distance between the color difference value of the reference image block and the color difference value of the final estimated light source color temperature point, that is, the color difference distance delta1 between the color difference value of the reference image block and the color temperature curve, the effective image block ratio may be further utilized to scale the distance value calculation result, so as to realize accurate adjustment of the distance value calculation result. At this time, the reference distance value may be expressed as delta 2=delta 1/ratio-priority.
And S53, if the reference distance value is smaller than the preset distance threshold value, the reference image block is used as a valid reference image block.
In a specific embodiment, the distance threshold value can be set reasonably according to actual conditions, and the intensity and the accuracy of the white balance correction can be adjusted by adjusting the distance threshold value.
S54-1, if the number of the effective reference image blocks is smaller than a preset number threshold, calculating the pixel gain of the automatic white balance by utilizing the color difference value of the final estimated light source color temperature point.
Specifically, the inverse of the color difference value of the final estimated light source color temperature point is directly used as the pixel gain of the automatic white balance, namely, the pixel gain of the R channel can be expressed as Rgain=1/ct_rg, and the pixel gain of the B channel can be expressed as Bgain =1/ct_bg.
S54-2, if the number of the effective reference image blocks is greater than or equal to a preset number threshold, calculating the pixel gain of the automatic white balance by using the sum of R channels, the sum of B channels and the sum of G channels of all the effective reference image blocks.
Specifically, the ratio of the sum of R channels to the sum of G channels of all valid reference image blocks is taken as the pixel gain of the R channels, i.e., rgain=r_sum/g_sum, where r_sum represents the sum of R channel values of all valid reference image blocks, g_sum represents the sum of G channel values of all valid reference image blocks, and the ratio of the sum of B channels to the sum of G channels of all valid reference image blocks is taken as the pixel gain of the B channels, i.e., bgain =b_sum/g_sum, where b_sum represents the sum of B channel values of all valid reference image blocks, g_sum represents the sum of G channel values of all valid reference image blocks.
Further, in the present embodiment, step S6 compensates the original image by using the calculated pixel gain to obtain an image after automatic white balance correction.
Specifically, the original R channel value of the original image is multiplied by the pixel gain of the R channel to obtain the R channel value after the white balance correction, and the original B channel value of the original image is multiplied by the pixel gain of the B channel to obtain the B channel value after the white balance correction. And combining the R channel value after the white balance correction, the B channel value after the white balance correction and the original G channel value, thereby obtaining an image after the white balance correction.
According to the automatic white balance method based on color temperature estimation, the color temperature curve is traversed roughly and then the color temperature curve is traversed finely to perform color temperature estimation, so that the color temperature estimation under various scenes can be met, and a more accurate color temperature estimation result can be obtained under the condition of less calculation amount. According to the automatic white balance method based on the color temperature estimation, when the color temperature estimation is carried out, the image blocks are screened through the color difference threshold, so that deviation influence of the bright image blocks and the dark image blocks on a calculation result is avoided, and the accuracy and reliability of the calculation result are ensured. According to the automatic white balance method based on the color temperature estimation, the light source priori score list is constructed, so that the distance is calibrated by using the priori score when the distance is calculated, and the light source estimation result is more accurate. According to the color temperature estimation-based automatic white balance method, the pixel gain calculation mode is distinguished according to the number of the effective reference image blocks, so that the pixel gain calculation result is more accurate and is more fit with the actual requirement, and the white balance correction effect is ensured.
The present embodiment also provides an automatic white balance device based on color temperature estimation, for implementing the automatic white balance method based on color temperature estimation as described above, as shown in fig. 8, including:
the image acquisition module is used for acquiring an original image;
the color temperature curve acquisition module is used for acquiring a color temperature curve;
The image block color difference calculation module is used for dividing an original image into a plurality of image blocks and calculating a color difference value of each image block;
The pixel gain calculation module is used for calculating to obtain a final estimated light source color temperature point by utilizing the color temperature curve and the color difference value of the image block, and calculating the pixel gain of the automatic white balance according to the final estimated light source color temperature point and the color difference value of the image block;
The white balance compensation module is used for compensating the original image by using the calculated pixel gain so as to obtain an image after automatic white balance correction;
and the image output module is used for outputting the image after the automatic white balance correction.
In practical application, the color temperature curve obtaining module can obtain the color temperature curve offline and store the obtained color temperature curve in the memory, so that the pre-stored color temperature curve is directly called from the memory when the automatic white balance device performs automatic white balance, and the processing efficiency of the automatic white balance is improved.
According to the automatic white balance device based on color temperature estimation, an original image is divided into a plurality of image blocks through the image block color difference calculation module, and the color temperature point of a light source is calculated and estimated according to the color difference value and the color temperature curve of the image blocks by the pixel gain calculation module, so that the color temperature of an estimated scene light source is more accurate, the calculated pixel gain is more accurate, the effect of automatic white balance correction is better, meanwhile, the automatic white balance device is distinguished and calculated through each functional module and matched with each other, the calculation process of each functional module is simple, the whole resource consumption of the device is less, the efficiency is high, the robustness is stronger, the device is suitable for various scenes, and the problems of poor existing white balance processing effect and limited application scenes are solved.
The embodiment also provides electronic equipment, which comprises a memory, a processor and an executable program which is stored in the memory and can be run by the processor, wherein the processor executes the automatic white balance method based on the color temperature estimation when running the executable program.
The embodiment also provides a computer storage medium storing an executable program which, when executed, implements the automatic white balance method based on color temperature estimation as described above.
In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the difference from other embodiments, so that the same similar parts of each embodiment are referred to each other.
The automatic white balance method and device based on color temperature estimation, electronic equipment and computer storage medium comprise the steps of obtaining a color temperature curve, dividing an original image into a plurality of image blocks, calculating a color difference value of each image block, calculating a final estimated light source color temperature point by utilizing the color temperature curve and the color difference value of the image block, calculating pixel gains of automatic white balance according to the final estimated light source color temperature point and the color difference value of the image block, and compensating the original image by utilizing the calculated pixel gains to obtain an image after automatic white balance correction. The method has the advantages that the original image is divided into a plurality of image blocks, the color temperature points of the light source are calculated and estimated by utilizing the color difference values and the color temperature curves of the image blocks, so that the color temperature of the estimated scene light source is more accurate, the calculated pixel gain is more accurate, the automatic white balance correction effect is better, meanwhile, the automatic white balance method has simple calculation process, less resource consumption, high efficiency and stronger robustness, is suitable for various scenes, and solves the problems of poor white balance treatment effect and limited application scene in the prior art.
The above description is only illustrative of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention, and any alterations and modifications made by those skilled in the art based on the above disclosure shall fall within the scope of the appended claims.

Claims (11)

1.一种基于色温估计的自动白平衡方法,其特征在于,包括:1. An automatic white balance method based on color temperature estimation, comprising: 获取色温曲线;Get the color temperature curve; 对原始图像进行分块,以得到多个图像块;Divide the original image into blocks to obtain multiple image blocks; 计算每一图像块的色差值;Calculate the color difference value of each image block; 利用色温曲线和图像块的色差值,计算得到最终估计光源色温点;The final estimated light source color temperature point is calculated using the color temperature curve and the color difference value of the image block; 根据最终估计光源色温点和图像块的色差值,计算自动白平衡的像素增益;Calculate the pixel gain of automatic white balance according to the final estimated light source color temperature point and the color difference value of the image block; 利用计算出的像素增益,对原始图像进行补偿,以得到自动白平衡校正后的图像。The calculated pixel gain is used to compensate the original image to obtain an image after automatic white balance correction. 2.根据权利要求1所述的基于色温估计的自动白平衡方法,其特征在于,所述获取色温曲线的方法包括:2. The automatic white balance method based on color temperature estimation according to claim 1, wherein the method for obtaining the color temperature curve comprises: 在不同的色温光源下分别拍摄色板卡,以得到不同色温的色温图像;Photograph the color plate cards under different color temperature light sources to obtain color temperature images with different color temperatures; 计算每一色温图像的R/G色差值和B/G色差值;Calculate the R/G color difference value and B/G color difference value of each color temperature image; 将每一色温图像的R/G色差值和B/G色差值作为曲线的横、纵坐标进行曲线拟合,以得到色温曲线。The R/G color difference value and the B/G color difference value of each color temperature image are used as the horizontal and vertical coordinates of the curve to perform curve fitting to obtain the color temperature curve. 3.根据权利要求2所述的基于色温估计的自动白平衡方法,其特征在于,所述计算每一色温图像的R/G色差值和B/G色差值的方法包括:3. The automatic white balance method based on color temperature estimation according to claim 2, wherein the method of calculating the R/G color difference value and the B/G color difference value of each color temperature image comprises: 对色温图像进行阴影校正;Perform shading correction on color temperature images; 获取校正后的色温图像在预设区域内的R通道、B通道和G通道的均值;Obtain the average values of the R channel, B channel and G channel of the corrected color temperature image in a preset area; 利用每一色温图像的R通道均值、B通道均值和G通道均值,计算该色温图像的R/G色差值和B/G色差值。The R/G color difference value and the B/G color difference value of each color temperature image are calculated using the R channel mean value, the B channel mean value and the G channel mean value of the color temperature image. 4.根据权利要求1所述的基于色温估计的自动白平衡方法,其特征在于,所述计算每一图像块的色差值的方法包括:4. The automatic white balance method based on color temperature estimation according to claim 1, wherein the method of calculating the color difference value of each image block comprises: 计算每一图像块中,R通道、B通道和G通道的均值;Calculate the mean of the R channel, B channel and G channel in each image block; 利用每一图像块的R通道均值、B通道均值和G通道均值,计算该图像块的R/G色差值和B/G色差值;Using the R channel mean, B channel mean and G channel mean of each image block, calculate the R/G color difference value and B/G color difference value of the image block; 设置亮度阈值;Set brightness threshold; 根据亮度阈值,筛选符合要求的图像块,并得到有效图像块比例。According to the brightness threshold, the image blocks that meet the requirements are screened and the ratio of valid image blocks is obtained. 5.根据权利要求1所述的基于色温估计的自动白平衡方法,其特征在于,所述利用色温曲线和每一图像块的色差值,计算得到最终估计光源色温点的方法包括:5. The automatic white balance method based on color temperature estimation according to claim 1, wherein the method of calculating the final estimated light source color temperature point by using the color temperature curve and the color difference value of each image block comprises: 按照第一步长遍历色温曲线,利用每一图像块的色差值,计算得到初始估计光源色温点;According to the first step, the color temperature curve is traversed, and the color difference value of each image block is used to calculate the initial estimated light source color temperature point; 在初始估计光源色温点的预设范围内,按照第二步长遍历色温曲线,并利用每一图像块的色差值,计算得到最终估计光源色温点;Within the preset range of the initially estimated light source color temperature point, traverse the color temperature curve according to the second step length, and calculate the final estimated light source color temperature point using the color difference value of each image block; 其中,第二步长小于第一步长。Among them, the second step length is smaller than the first step length. 6.根据权利要求5所述的基于色温估计的自动白平衡方法,其特征在于,所述按照第一步长遍历色温曲线,利用每一图像块的色差值,计算得到初始估计光源色温点的方法包括:6. The automatic white balance method based on color temperature estimation according to claim 5, characterized in that the method of traversing the color temperature curve according to the first step and calculating the initial estimated light source color temperature point using the color difference value of each image block comprises: 获取不同亮度水平的光源先验得分列表;Get a list of prior scores for light sources at different brightness levels; 按照第一步长遍历色温曲线,在每一色温点计算每一图像块的色差值与该色温点色差值的距离之和,以得到第一距离值;Traversing the color temperature curve according to the first step, calculating the sum of the distances between the color difference value of each image block and the color difference value of the color temperature point at each color temperature point, to obtain a first distance value; 从光源先验得分列表中获取每一色温点所对应的先验得分;Obtain the prior score corresponding to each color temperature point from the light source prior score list; 将第一距离值减去其对应的色温点所对应的先验得分,以得到第二距离值;Subtract the a priori score corresponding to the corresponding color temperature point from the first distance value to obtain a second distance value; 将最小的第二距离值所对应的色温点作为初始估计光源色温点。The color temperature point corresponding to the smallest second distance value is used as the initial estimated light source color temperature point. 7.根据权利要求6所述的基于色温估计的自动白平衡方法,其特征在于,所述在初始估计光源色温点的预设范围内,按照第二步长遍历色温曲线,并利用每一图像块的色差值,计算得到最终估计光源色温点的方法包括:7. The automatic white balance method based on color temperature estimation according to claim 6, characterized in that the method of traversing the color temperature curve according to the second step length within the preset range of the initially estimated light source color temperature point and calculating the final estimated light source color temperature point by using the color difference value of each image block comprises: 在初始估计光源色温点的预设范围内,按照第二步长遍历色温曲线,在每一色温点计算每一图像块的色差值与该色温点色差值的距离之和,以得到第三距离值;Within a preset range of the initially estimated light source color temperature point, traverse the color temperature curve according to the second step length, and calculate the sum of the distances between the color difference value of each image block and the color difference value of the color temperature point at each color temperature point to obtain a third distance value; 从光源先验得分列表中获取每一色温点所对应的先验得分;Obtain the prior score corresponding to each color temperature point from the light source prior score list; 将第三距离值减去其对应的色温点所对应的先验得分,以得到第四距离值;Subtract the a priori score corresponding to the color temperature point corresponding to the third distance value to obtain a fourth distance value; 将最小的第四距离值所对应的色温点作为最终估计光源色温点。The color temperature point corresponding to the smallest fourth distance value is used as the final estimated light source color temperature point. 8.根据权利要求6所述的基于色温估计的自动白平衡方法,其特征在于,所述根据最终估计光源色温点和图像块的色差值,计算自动白平衡的像素增益的方法包括:8. The automatic white balance method based on color temperature estimation according to claim 6, characterized in that the method of calculating the pixel gain of the automatic white balance according to the color difference value of the final estimated light source color temperature point and the image block comprises: 将与最终估计光源色温点的色差值的距离在预设距离内的图像块作为参考图像块;An image block whose color difference value is within a preset distance from the final estimated light source color temperature point is used as a reference image block; 计算每一参考图像块的色差值与最终估计光源色温点的色差值的距离与先验得分的差值,以得到参考距离值;Calculate the difference between the distance between the color difference value of each reference image block and the color difference value of the final estimated light source color temperature point and the prior score to obtain a reference distance value; 若参考距离值小于预设距离阈值,则将该参考图像块作为有效参考图像块;If the reference distance value is less than the preset distance threshold, the reference image block is used as a valid reference image block; 若有效参考图像块的个数小于预设个数阈值,则利用最终估计光源色温点的色差值计算自动白平衡的像素增益;If the number of valid reference image blocks is less than a preset number threshold, the color difference value of the final estimated light source color temperature point is used to calculate the pixel gain of the automatic white balance; 若有效参考图像块的个数大于等于预设个数阈值,则利用所有有效参考图像块的R通道总和、B通道总和和G通道总和计算自动白平衡的像素增益。If the number of valid reference image blocks is greater than or equal to a preset number threshold, the pixel gain of the automatic white balance is calculated using the sum of the R channels, the sum of the B channels, and the sum of the G channels of all valid reference image blocks. 9.一种基于色温估计的自动白平衡装置,用于实现如权利要求1~8任一项所述的基于色温估计的自动白平衡方法,其特征在于,所述基于色温估计的自动白平衡装置包括:9. An automatic white balance device based on color temperature estimation, used to implement the automatic white balance method based on color temperature estimation according to any one of claims 1 to 8, characterized in that the automatic white balance device based on color temperature estimation comprises: 图像获取模块,用于获取原始图像;An image acquisition module, used for acquiring original images; 色温曲线获取模块,用于获取色温曲线;A color temperature curve acquisition module is used to acquire a color temperature curve; 图像块色差计算模块,用于对原始图像进行分块以得到多个图像块,并计算每一图像块的色差值;An image block color difference calculation module is used to divide the original image into blocks to obtain multiple image blocks, and calculate the color difference value of each image block; 像素增益计算模块,用于利用色温曲线和每一图像块的色差值,计算得到最终估计光源色温点,并根据最终估计光源色温点和图像块的色差值,计算自动白平衡的像素增益;A pixel gain calculation module, used to calculate the final estimated light source color temperature point using the color temperature curve and the color difference value of each image block, and calculate the pixel gain of automatic white balance according to the final estimated light source color temperature point and the color difference value of the image block; 白平衡补偿模块,用于利用计算出的像素增益,对原始图像进行补偿,以得到自动白平衡校正后的图像;A white balance compensation module is used to compensate the original image using the calculated pixel gain to obtain an image after automatic white balance correction; 图像输出模块,用于输出自动白平衡校正后的图像。The image output module is used to output the image after automatic white balance correction. 10.一种电子设备,其特征在于,包括存储器、处理器及存储在存储器上并能够由所述处理器运行的可执行程序;所述处理器运行所述可执行程序时执行如权利要求1~8任一项所述的基于色温估计的自动白平衡方法。10. An electronic device, characterized in that it comprises a memory, a processor, and an executable program stored in the memory and capable of being run by the processor; when the processor runs the executable program, the automatic white balance method based on color temperature estimation as described in any one of claims 1 to 8 is executed. 11.一种计算机存储介质,其特征在于,所述计算机存储介质存储有可执行程序;所述可执行程序被执行时,实现如权利要求1~8任一项所述的基于色温估计的自动白平衡方法。11. A computer storage medium, characterized in that the computer storage medium stores an executable program; when the executable program is executed, the automatic white balance method based on color temperature estimation as described in any one of claims 1 to 8 is implemented.
CN202510538198.7A 2025-04-25 2025-04-25 Automatic white balance method and device based on color temperature estimation, electronic device and computer storage medium Pending CN120343175A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202510538198.7A CN120343175A (en) 2025-04-25 2025-04-25 Automatic white balance method and device based on color temperature estimation, electronic device and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202510538198.7A CN120343175A (en) 2025-04-25 2025-04-25 Automatic white balance method and device based on color temperature estimation, electronic device and computer storage medium

Publications (1)

Publication Number Publication Date
CN120343175A true CN120343175A (en) 2025-07-18

Family

ID=96354872

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202510538198.7A Pending CN120343175A (en) 2025-04-25 2025-04-25 Automatic white balance method and device based on color temperature estimation, electronic device and computer storage medium

Country Status (1)

Country Link
CN (1) CN120343175A (en)

Similar Documents

Publication Publication Date Title
CN112752023B (en) Image adjusting method and device, electronic equipment and storage medium
US9723285B2 (en) Multi-area white-balance control device, multi-area white-balance control method, multi-area white-balance control program, computer in which multi-area white-balance control program is recorded, multi-area white-balance image-processing device, multi-area white-balance image-processing method, multi-area white-balance image-processing program, computer in which multi-area white-balance image-processing program is recorded, and image-capture apparatus
CN106373523B (en) Spliced bright and dark line compensation method
EP2426928B1 (en) Image processing apparatus, image processing method and program
US8854709B1 (en) Automatic white balance based on dynamic mapping
CN106131526B (en) A kind of white balancing treatment method and device based on rgb space
US8243163B2 (en) Adjusting auto white balance
EP1592227A2 (en) Apparatus and method for determining an image processing parameter from image data at a user-selected image position
CN108234971B (en) White balance parameter determines method, white balance adjustment method and device, storage medium, terminal
CN101061704B (en) Color adjusting device and method
JP2003520515A (en) Color signal processing
CN112669758A (en) Display screen correction method, device, system and computer readable storage medium
WO2019010917A1 (en) Method and system for color calibration of projection image
CN108347600A (en) Industrial camera bearing calibration and system
Garud et al. A fast auto white balance scheme for digital pathology
KR20210155743A (en) Method for image processing of high dynamic range sensors for handling white balance
KR101694621B1 (en) Apparatus and method for estimating brightness using image sensor of auto exposure data
KR101680446B1 (en) Creation device for color table, correction and control device for camera image and method thereof
Zhao et al. Spectral illumination correction: Achieving relative color constancy under the spectral domain
JP2000148978A (en) Method and device for estimating photographic light source, method and device for processing image and recording medium
CN120343175A (en) Automatic white balance method and device based on color temperature estimation, electronic device and computer storage medium
JP6196882B2 (en) Multi-area white balance control device, multi-area white balance control method, multi-area white balance control program, computer recording multi-area white balance control program, multi-area white balance image processing device, multi-area white balance image processing method, multi-area White balance image processing program, computer recording multi-area white balance image processing program, and imaging apparatus provided with multi-area white balance image processing device
CN113709429A (en) Color correction method and color correction system
CN114723632B (en) A method and device for correcting abnormal exposure images of parts based on texture information
JP4802333B2 (en) Method for determining exposure ratio in image composition

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