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.
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.