Color temperature estimation method, white balance adjustment method, device and storage medium
By screening and calculating the target estimated color temperature of the skin color patches in the image, the problem of color temperature estimation errors in the existing technology is solved, the accuracy and adaptability of the white balance algorithm are improved, and the image effect on different backgrounds is ensured to be good.
Patent Information
- Application Number
- CN202111542228.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-16
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-12-16
AI Technical Summary
The existing technology is prone to color temperature estimation errors when processing solid-color backgrounds, resulting in poor face image correction effects, and is unable to provide good image effects on pure blue backgrounds while maintaining the general adaptability of the white balance algorithm.
By screening the target skin color patch, calculate its target estimated color temperature, use the calibration parameter values of R/G value and B/G value to determine the skin color patch interval, and bring it into the calibration color temperature curve to calculate the target estimated color temperature, avoiding a single Color temperature estimation errors caused by the same color and skin tone, while maintaining the adaptability of the white balance algorithm.
It improves the color temperature estimation accuracy of the white balance algorithm, avoids color temperature estimation errors, ensures good image effects under different color temperatures, and maintains the universal adaptability of the white balance algorithm.
Smart Images

Figure CN114500968B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of white balance, and in particular to a color temperature estimation method, a white balance adjustment method, a device and a storage medium. Background Art
[0002] In indoor scenes, close-up portraits are usually taken against a pure-color background and in scenes with multiple color temperatures. HiSilicon's built-in white balance algorithm considers the distribution of global white pixels when calculating the color temperature of the scene, which can easily lead to incorrect color temperature estimation. If a large area of a single color and skin color exist in the image, it will lead to incorrect color temperature estimation, resulting in poor facial image correction results.
[0003] Previous devices had two main solutions for dealing with pure color backgrounds: one was to limit the upper and lower limits of color temperature to ensure that there would be no large-scale color cast on the pure color background; the second was to increase the restrictions on the automatic white balance algorithm for screening white pixels to ensure that the correct white pixels and gray pixels could be found, thereby improving the accuracy of the automatic white balance algorithm's color temperature estimation. The above two methods can improve the accuracy of the white balance algorithm's color temperature estimation, but at the expense of the white balance algorithm's universal adaptability, resulting in worse image effects at medium and low color temperatures on a pure blue background than before. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a color temperature estimation method, a white balance adjustment method, a device and a storage medium, which screen out a target skin color block and then calculate the target estimated color temperature of the target skin color block to solve the problem of inaccurate color temperature estimation in the prior art while maintaining the universal adaptability of the white balance algorithm.
[0005] In a first aspect, the present invention provides a color temperature estimation method, comprising the following steps: acquiring a current frame image and identifying a face area in the current frame image, wherein the face area is composed of a plurality of blocks; calculating a calibration parameter value for each block in the face area; determining a skin color block interval according to the calibration parameter value, and screening out a target skin color block from the block; determining whether the target skin color block exists; if so, calculating an average value of the calibration parameter value of the target skin color block; and substituting the average value of the calibration parameter value of the target skin color block into a calibration color temperature curve to calculate a target estimated color temperature.
[0006] Further, the calibration parameter values include R / G values and B / G values; the step of determining the skin color block interval according to the calibration parameter values and filtering out the target skin color block from the block specifically includes: respectively determining the maximum and minimum values of the R / G values and the B / G values in the face area to obtain the R / G interval and the B / G interval; determining the first skin color interval according to the R / G interval and the R / G values of each of the blocks in the face area, and determining the second skin color interval according to the B / G interval and the B / G values of each of the blocks in the face area; if the R / G value of the current block falls into the first skin color interval and the B / G value falls into the second skin color interval, then the current block is the target skin color block.
[0007] Further, determining the first skin color interval based on the R / G interval and the R / G values of each block in the face area includes: dividing the R / G interval into a plurality of continuous first sub-intervals according to a preset distance; counting the number of blocks whose R / G values fall into each of the first sub-intervals; and taking the first sub-interval containing the largest number of blocks as the first skin color interval; determining the second skin color interval based on the B / G interval and the B / G values of each block in the face area includes: dividing the B / G interval into a plurality of continuous second sub-intervals according to a preset distance; counting the number of blocks whose B / G values fall into each of the second sub-intervals; and taking the second sub-interval containing the largest number of blocks as the second skin color interval.
[0008] Furthermore, the method further includes: if the target skin color block does not exist, entering the step of determining the skin color block interval according to the calibration parameter value to expand the range of the skin color block interval.
[0009] Furthermore, the average values of the calibration parameter values of the target skin color block include the average values of R / G and the average values of B / G; the calibration color temperature curve includes the R / G-color temperature relationship curve and the B / G-color temperature relationship curve; the step of substituting the average values of the calibration parameter values of the target skin color block into the calibration color temperature curve to calculate the target estimated color temperature includes: substituting the average value of R / G into the R / G-color temperature relationship curve to obtain a first estimated color temperature; substituting the average value of B / G into the B / G-color temperature relationship curve to obtain a second estimated color temperature; and calculating the target estimated color temperature based on the first estimated color temperature and the second estimated color temperature.
[0010] Furthermore, a target estimated color temperature is calculated based on the first estimated color temperature and the second estimated color temperature, including: calculating the difference between the first estimated color temperature and the second estimated color temperature; determining whether the difference is less than a preset threshold value; if so, calculating the average value of the first estimated color temperature and the second estimated color temperature as the target estimated color temperature; if not, determining whether the current skin color block screening times exceeds a preset maximum number of iterations, if it exceeds the preset maximum number of iterations, calculating the average value of the first estimated color temperature and the second estimated color temperature in all iterations as the target estimated color temperature or calculating the average value of the second estimated color temperature in all iterations as the target estimated color temperature, if it does not exceed the preset maximum number of iterations, expanding the range of the first skin color interval and the second skin color interval, and entering the step of determining the skin color block interval according to the calibration parameter value to expand the range of the skin color block interval.
[0011] Furthermore, the method also includes: respectively obtaining R, G, and B three-channel response values of different skin color blocks at different color temperatures; respectively calculating the R / G value and B / G value of each skin color block at each color temperature according to each of the R, G, and B three-channel response values as calibration parameter values of the skin color block; and obtaining the calibration color temperature curve by fitting according to each of the calibration parameter values and the color temperature corresponding to the calibration parameter value.
[0012] In a second aspect, the present invention also provides a white balance adjustment method, comprising the following steps: obtaining a target estimated color temperature calculated by the color temperature estimation method; calculating a white balance gain based on the target estimated color temperature, and using the white balance gain as a white balance manual gain to adjust the white balance.
[0013] In a third aspect, the present invention provides a color temperature estimation device, comprising: a first acquisition module, configured to acquire a current frame image and identify a face area in the current frame image, wherein the face area is composed of a plurality of blocks; a first calculation module, configured to calculate a calibration parameter value for each block in the face area; a screening module, configured to determine a skin color block interval according to the calibration parameter value, and screen out a target skin color block from the block; a judgment module, configured to judge whether the target skin color block exists; if so, calculate the average value of the calibration parameter value of the target skin color block; and a second calculation module, configured to bring the average value of the calibration parameter value of the target skin color block into a calibration color temperature curve to calculate a target estimated color temperature.
[0014] In a fourth aspect, the present invention provides a white balance adjustment device, comprising: a second acquisition module, configured to obtain a target estimated color temperature calculated by the color temperature estimation device; a third calculation module, configured to calculate a white balance gain based on the target estimated color temperature, and use the white balance gain as a white balance manual gain to adjust the white balance.
[0015] In a fifth aspect, the present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the color temperature estimation method or the white balance adjustment method.
[0016] The technical solution of this application has the following advantages:
[0017] The present application provides a color temperature estimation method, a white balance adjustment method, a device and a storage medium, which screen out the skin color blocks in the image and calculate the target estimated color temperature of the skin color blocks, thereby avoiding the problem of incorrect color temperature estimation caused by the same single color and skin color in the image.
[0018] The white balance adjustment method provided in the present application obtains the target estimated color temperature and calculates the white balance gain, thereby ultimately improving the effect of the white balance adjustment. The present application estimates the target estimated color temperature by calibrating the skin color block. It is not limited to the upper and lower limits of the color temperature and the screening of white pixels in the white balance algorithm, thereby maintaining the adaptability of the white balance algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figures 1 to 4 is a flow chart of a color temperature estimation method provided according to an embodiment of the present invention;
[0021] Figure 5 is a flow chart of a white balance adjustment method provided according to an embodiment of the present invention;
[0022] Figures 6-7 is a structural block diagram of a color temperature estimation device provided according to an embodiment of the present invention;
[0023] Figure 8 is a structural block diagram of a white balance adjustment device provided according to an embodiment of the present invention;
[0024] Fig. 9 is a schematic diagram of the hardware structure of a white balance terminal provided by an embodiment of the present invention;
[0025] Fig.10 4 is a structural block diagram of a white balance adjustment system provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0027] In one embodiment, the present invention provides a color temperature estimation method, which screens out the skin color blocks in an image and calculates the target estimated color temperature of the skin color blocks, thereby avoiding the problem of color temperature estimation error caused by the same single color in the image as the skin color. Figure 1 As shown, the color temperature estimation method includes the following steps: S1 to S5.
[0028] S1. Acquire a current frame image and identify a face region in the current frame image, wherein the face region is composed of a plurality of blocks.
[0029] Specifically, the current frame image is the image that currently needs to be estimated in color temperature. The current frame image may be a real-time image acquired by calling a camera interface, or may be a pre-stored image or an image captured from a historical video stream. The acquisition method of the current frame image is not limited herein. Further, a face recognition algorithm is used to perform face recognition on the acquired current frame image to identify a face area in the current frame image.
[0030] Specifically, the entire frame image is divided into multiple blocks, the block corresponding to the face area is determined according to the position mapping of the face area on the entire frame image obtained by the face recognition algorithm, and the white balance statistical information of the block of the face area is obtained, and the white balance statistical information includes the R, G, and B three-channel response values of the block.
[0031] Furthermore, the current frame image includes one or more face regions, and each face region is composed of multiple blocks.
[0032] S2. Calculate the calibration parameter value of each block in the face area.
[0033] The calibration parameter value refers to the color characteristic value of each block, which is used to calibrate each block according to the three-channel response value.
[0034] Specifically, according to the R, G, and B channel response values of each block, the R / G value and B / G value of each block are calculated as the calibration parameter values of each block in the face area. Since the current frame image obtained will be warmer (red) or cooler (blue), the contrast between the two is stronger and also greatly affects the quality of the image; therefore, the effect of adjusting the R / G value and the B / G value is better.
[0035] S3. Determine a skin color block interval according to the calibration parameter value, and select a target skin color block from the block.
[0036] Specifically, the skin color block interval is determined according to the calibration parameter value, and the target skin color block is screened out from the block according to the calibration parameter value and the skin color block interval.
[0037] In one embodiment, if there is only one face region, the skin color block interval is determined according to the calibration parameter value in the face region, and the target skin color block is screened out from the blocks in the face region.
[0038] In one embodiment, if the current frame image includes multiple face areas, determining the skin color block interval according to the calibration parameter value, and filtering out the target skin color block from the block includes: determining the skin color block interval corresponding to each face area according to the calibration parameter value of each block in each face area, and filtering out the target skin color block of each face area from the block corresponding to each face area.
[0039] In another embodiment, if the current frame image includes multiple face areas, determining the skin color block interval according to the calibration parameter value, and filtering out the target skin color block from the block includes: determining the skin color block interval in combination with the calibration parameter values of the blocks in all face areas, and filtering out the target skin color block from the blocks in all face areas.
[0040] In one embodiment, if Figure 2 As shown, the calibration parameter values include R / G values and B / G values; the steps of determining the skin color block interval according to the calibration parameter values and selecting the target skin color block from the block specifically include S301 to S303.
[0041] S301, respectively determine the maximum and minimum values of the R / G value and the B / G value in the face area to obtain the R / G interval and the B / G interval.
[0042] Specifically, each block in the face area corresponds to a unique R / G value and B / G value. The maximum and minimum values are determined from the R / G values of all blocks in the face area to obtain the R / G interval, and the maximum and minimum values are determined from the B / G values of all blocks in the face area to obtain the B / G interval.
[0043] Furthermore, if multiple face areas are included, the maximum and minimum values are determined from the R / G values of the blocks in all face areas to obtain the R / G interval, and the maximum and minimum values are determined from the B / G values of the blocks in all face areas to obtain the B / G interval, that is, all face areas correspond to one R / G interval and one B / G interval; or; the maximum and minimum values in the R / G values of the blocks in each face area are determined separately to obtain the R / G interval, and the maximum and minimum values in the B / G values of the blocks in each face area are determined separately to obtain the B / G interval, that is, each face area corresponds to one R / G interval and one B / G interval.
[0044] S302, determining a first skin color interval according to an R / G interval and the R / G values of each of the blocks in the face area, and determining a second skin color interval according to a B / G interval and the B / G values of each of the blocks in the face area.
[0045] The first skin color interval and the second skin color interval constitute the skin color block interval.
[0046] Specifically, if there are multiple face regions, and all face regions correspond to one R / G interval and one B / G interval, then all face regions correspond to one first skin color interval and one second skin color interval. If there are multiple face regions, and each face region corresponds to one R / G interval and one B / G interval, then each face region corresponds to one first skin color interval and one second skin color interval. If there is only one face region, then the face region corresponds to one first skin color interval and one second skin color interval.
[0047] In a specific embodiment, determining the first skin color interval according to the R / G interval and the R / G values of each block in the face region includes: dividing the R / G interval into a plurality of continuous first sub-intervals according to a preset distance; counting the number of blocks whose R / G values fall into each of the first sub-intervals; and taking the first sub-interval containing the largest number of blocks as the first skin color interval. Determining the second skin color interval according to the B / G interval and the B / G values of each block in the face region includes: dividing the B / G interval into a plurality of continuous second sub-intervals according to a preset distance; counting the number of blocks whose B / G values fall into each of the second sub-intervals; and taking the second sub-interval containing the largest number of blocks as the second skin color interval.
[0048] This embodiment divides the R / G interval or the B / G interval into multiple continuous sub-intervals, and counts the number of blocks whose R / G values or B / G values fall into each sub-interval, and uses the sub-interval containing the largest number of blocks as the skin color block interval, namely the first skin color interval and the second skin color interval. This can effectively filter out blocks with large R / G value or B / G value deviations, thereby improving the accuracy of skin color block screening; further, the size of the sub-interval can be adjusted to adjust the range of the first skin color interval and the second skin color interval. Such parameter adjustment is convenient and rapid, and the skin color block interval can be adjusted according to the screening results to ensure effective screening of the target skin color block.
[0049] In another embodiment, the first skin color interval is determined according to the R / G interval and the R / G values of each block in the face area, including: counting the normal distribution of the R / G values of each block in the R / G interval, and taking (μ-a, μ+a) as the first skin color interval, wherein μ is the mean of the normal distribution, a is a constant, and the first skin color interval can be adjusted by adjusting the value of a. The second skin color interval is selected in the same manner as the first skin color interval. In this embodiment, the corresponding skin color block interval is selected using the normal distribution method, and the area with a relatively concentrated distribution can be selected as the skin color block interval according to the distribution of the R / G values and B / G values in each block, which has statistical significance and is conducive to improving the screening accuracy and success rate of the target skin color block.
[0050] In other embodiments, the center value of the R / G interval or the B / G interval can be selected to obtain and determine whether the number of blocks within a certain distance accounts for half or more of the total number of blocks based on the R / G value of each block or the distance between the B / G value and the center value. If so, the difference between the center value and the distance and the interval formed by the sum of the center value and the distance are used as the skin color block interval. For example, there are 5 blocks in the face area, and the R / G values of each block are 3, 7, 8, 11, and 13, respectively. The center value of the R / G interval is 8, and the distances between the R / G values of each block and the center value are 5, 1, 0, 3, and 5, respectively; there are 3 blocks within a distance of 3, and the first skin color interval is (5, 11).
[0051] S303: If the R / G value of the current block falls within the first skin color range and the B / G value falls within the second skin color range, the current block is a target skin color block.
[0052] Specifically, the current block refers to any block in the face area of the current frame image, and each block can be used as the current block in turn to confirm whether it is the target skin color block, until all blocks in the face area are traversed, and all blocks in the face area whose R / G values fall into the first skin color interval and whose B / G values fall into the second skin color interval are used as target skin color blocks. Blocks whose R / G values and B / G values meet the conditions at the same time are used as target skin color blocks, and the target skin color blocks are jointly determined from two different dimensions, thereby improving the accuracy of target skin color block screening.
[0053] S4. Determine whether the target skin color block exists; if so, calculate the average value of the calibration parameter value of the target skin color block.
[0054] In one embodiment, the average value of the calibration parameter value of the target skin color block includes the average value of R / G and the average value of B / G.
[0055] Specifically, if the number of the target skin color blocks is only 1, the average value of the calibration parameter value of the target skin color block is the R / G value and the B / G value of the current target skin color block. If the number of the target skin color blocks is greater than 1, the average value of the R / G value and the average value of the B / G value of all the current target skin color blocks are calculated as the average value of the calibration parameter value of the target skin color block. In one embodiment, if the target skin color block does not exist, the step of determining the skin color block interval according to the calibration parameter value is re-executed to expand the range of the skin color block interval.
[0056] Specifically, when no target skin color block that meets the conditions is screened out according to the current skin color block interval, it means that the screening range of the current skin color block interval is narrow, therefore, the range of the skin color block interval is expanded to screen the target skin color block again. Specifically, a skin color block interval with a larger range is re-determined according to the calibration parameter value, and the target skin color block is re-screened from the block according to the re-determined skin color block interval with a larger range. Further, the skin color block interval range can be expanded according to the specific method of obtaining the skin color block interval. For example, if the skin color block interval is obtained by dividing the continuous sub-intervals in the R / G interval and the B / G interval, the skin color block interval can be expanded by expanding the length of each sub-interval when dividing the sub-interval, such as expanding the length of the sub-interval from 10 to 15; or by selecting the first two sub-intervals containing a larger number of blocks as the skin color block interval; if the skin color block interval is determined by the mean of the normal distribution, the skin color block interval can be expanded by increasing the value of a.
[0057] This implementation increases the probability of successful screening of the target skin color block by expanding the skin color block interval range to screen the target skin color block again.
[0058] S5. Substitute the average value of the calibration parameter value of the target skin color block into the calibration color temperature curve to calculate the target estimated color temperature.
[0059] Specifically, if there is only one face region or multiple face regions corresponding to one skin color block interval, the average value of the calibration parameters of the screened target skin color block is directly substituted into the calibration color temperature curve to obtain the target estimated color temperature.
[0060] In one embodiment, if there are multiple face areas, and each face area corresponds to a skin color block interval, the average value of the calibration parameters of the target skin color block corresponding to each face area is respectively substituted into the calibration color temperature curve to obtain the initial estimated color temperature; then, weights are set according to the size of each face area, and the target estimated color temperature is obtained by weighted average of the weights corresponding to each face area and the initial estimated color temperature; or, the average value of each initial estimated color temperature is calculated as the target estimated color temperature; or, the median value of each initial estimated color temperature is taken as the target estimated color temperature.
[0061] In the case of multiple face regions, each face is used to obtain an initial estimated color temperature and multiple initial estimated color temperatures are used to obtain the target estimated color temperature. The influence of all face regions is comprehensively considered, which can further improve the accuracy of the target estimated color temperature. Furthermore, different weights are set according to the size of each face region to refine the influence of different face regions on the target estimated color temperature, further improving the accuracy of the target estimated color temperature.
[0062] In one embodiment, the calibration color temperature curve includes an R / G-color temperature relationship curve and a B / G-color temperature relationship curve; Figure 3 As shown, the step of bringing the average value of the calibration parameter value of the target skin color block into the calibration color temperature curve to calculate the target estimated color temperature includes S501-S502.
[0063] S501, substituting the average value of R / G into the R / G-color temperature relationship curve to obtain a first estimated color temperature; substituting the average value of B / G into the B / G-color temperature relationship curve to obtain a second estimated color temperature.
[0064] S502: Calculate a target estimated color temperature according to the first estimated color temperature and the second estimated color temperature.
[0065] Specifically, in a specific embodiment, calculating the target estimated color temperature based on the first estimated color temperature and the second estimated color temperature includes: calculating the difference between the first estimated color temperature and the second estimated color temperature; judging whether the difference is less than a preset threshold value, the preset threshold value is 300-500, and is 400 in the present embodiment; if so, calculating the average value of the first estimated color temperature and the second estimated color temperature as the target estimated color temperature; if not, judging whether the current skin color block screening times exceeds the preset maximum number of iterations, if it exceeds the preset maximum number of iterations, calculating the average value of the first estimated color temperature and the second estimated color temperature in all iterations as the target estimated color temperature, or calculating the average value of the second estimated color temperature in all iterations as the target estimated color temperature; if it does not exceed the preset maximum number of iterations, entering the step of determining the skin color block interval based on the calibration parameter value to expand the range of the skin color block interval.
[0066] In this embodiment, by comparing the difference between the first estimated color temperature and the second estimated color temperature with a preset threshold, it is determined whether the estimated color temperature obtained by the R / G value and the B / G value has a large deviation. If so, the estimated color temperature is re-determined to improve the accuracy of the target estimated color temperature. Further, when re-determining the target estimated color temperature, a maximum number of iterations is set to avoid iterating all the time while ensuring the accuracy of the target estimated color temperature, thereby saving memory and power consumption. Further, since the first estimated color temperature is a color temperature estimated based on the average value of R / G, that is, the first estimated color temperature has a higher correlation with the red component, and the red component in the human face skin color is higher than the blue component, the R / G value changes more sensitively and has a relatively low stability. Therefore, in one embodiment, when the difference between the first estimated color temperature and the second estimated color temperature is greater than the threshold and the number of skin color block screenings exceeds the preset maximum number of iterations, only the average value of the second estimated color temperature is used as the target estimated color temperature, which can effectively improve the accuracy of the target estimated color temperature.
[0067] In another embodiment, the target estimated color temperature is calculated according to the first estimated color temperature and the second estimated color temperature by calculating a weighted average of the first estimated color temperature and the second estimated color temperature.
[0068] In one embodiment, if Figure 4 As shown, the specific acquisition of the calibrated color temperature curve includes the following steps: S201 to S203.
[0069] S201, respectively obtaining R, G, and B three-channel response values of different skin color blocks at different color temperatures;
[0070] S202, respectively calculating the R / G value and the B / G value of each skin color block at each color temperature according to each of the R, G, B three-channel response values as calibration parameter values of the skin color block.
[0071] S203 , obtaining the calibrated color temperature curve by fitting according to the calibrated parameter values and the color temperatures corresponding to the calibrated parameter values.
[0072] The calibrated color temperature curve includes an R / G-color temperature relationship curve and a B / G-color temperature relationship curve.
[0073] In one embodiment, Figure 5 As shown, the present application provides a white balance adjustment method, comprising the following steps S601 to S602.
[0074] S601: Obtain a target estimated color temperature calculated by the color temperature estimation method.
[0075] S602: Calculate a white balance gain according to the target estimated color temperature, and use the white balance gain as a white balance manual gain to adjust the white balance.
[0076] The white balance adjustment method provided by the present invention obtains the target estimated color temperature of the skin color block calculated by any of the above color temperature estimation methods, thereby avoiding the problem of color temperature estimation error caused by the single color in the image being the same as the skin color. Ultimately, the effect of white balance adjustment is improved. The present invention estimates the target estimated color temperature by calibrating the skin color block, and is not limited to the upper and lower limits of the color temperature and the screening of white pixels in the white balance algorithm, thereby maintaining the adaptability of the white balance algorithm.
[0077] In one embodiment, Figure 6 As shown, the present application provides a color temperature estimation device, including: a first acquisition module 11, a first calculation module 12, a screening module 13, a judgment module 14 and a second calculation module 15.
[0078] The first acquisition module 11 is configured to acquire a current frame image and identify a face region in the current frame image, where the face region is composed of a plurality of blocks.
[0079] The first calculation module 12 is configured to calculate a calibration parameter value of each block in the face region.
[0080] The screening module 13 is configured to determine the skin color block interval according to the calibration parameter value, and screen out the target skin color block from the block.
[0081] The determination module 14 is configured to determine whether the target skin color block exists; if so, calculate the average value of the calibration parameter value of the target skin color block.
[0082] The second calculation module 15 is configured to bring the average value of the calibration parameter value of the target skin color block into the calibration color temperature curve to calculate the target estimated color temperature.
[0083] The calibration parameter values include R / G value and B / G value; Figure 7 As shown, the screening module 13 includes: a first determining unit 131 , a second determining unit 132 and a judging unit 133 .
[0084] The first determination module 131 is configured to respectively determine the maximum and minimum values of the R / G value and the B / G value in the face area to obtain the R / G interval and the B / G interval.
[0085] The second determination module 132 is configured to determine a first skin color interval according to an R / G interval and an R / G value of each of the blocks in the face area, and to determine a second skin color interval according to a B / G interval and a B / G value of each of the blocks in the face area.
[0086] The determination module 133 is configured to determine that if the R / G value of the current block falls within the first skin color interval and the B / G value falls within the second skin color interval, the current block is a target skin color block.
[0087] The present invention provides a color temperature estimation device, which screens out skin color blocks in an image and calculates a target estimated color temperature of the skin color blocks, thereby avoiding the problem of color temperature estimation error caused by a single color in the image being the same as the skin color.
[0088] In one embodiment, Figure 8 As shown, the present application provides a white balance adjustment device, including: a second acquisition module 21 and a third calculation module 22.
[0089] The second acquisition module 21 is configured to acquire the target estimated color temperature calculated by the color temperature estimation device in any embodiment.
[0090] The third calculation module 22 is configured to calculate a white balance gain according to the target estimated color temperature, and use the white balance gain as a white balance manual gain to adjust the white balance.
[0091] The white balance adjustment device provided by the present invention obtains the target estimated color temperature of the skin color block calculated by the color temperature estimation device, thereby avoiding the problem of color temperature estimation error caused by the single color in the image being the same as the skin color. Ultimately, the effect of white balance adjustment is improved. The present invention estimates the target estimated color temperature by calibrating the skin color block, and is not limited to the upper and lower limits of the color temperature and the screening of white pixels in the white balance algorithm, thereby maintaining the adaptability of the white balance algorithm.
[0092] The color temperature estimation device and the white balance adjustment device are used to implement the above device embodiments and preferred implementations, and will not be repeated here. As used above, the term "module" may be a combination of software and / or hardware that implements a predetermined function. Although the device described in the above embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0093] The color temperature estimation device and the white balance adjustment device are presented in the form of functional modules, where the modules refer to ASIC circuits, processors and memories that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0094] The further functional description of each of the above modules is the same as that of the above corresponding device embodiments and will not be repeated here.
[0095] In one embodiment, the present application provides a white balance adjustment terminal, see Fig. 9 , a structural schematic diagram of a white balance adjustment terminal is provided, and the terminal may include: at least one processor 51, such as a CPU (Central Processing Unit), at least one communication interface 53, a memory 54, and at least one communication bus 52. The communication bus 52 is used to realize the connection and communication between these components. The communication interface 53 may include a display screen (Display) and a keyboard (Keyboard), and the optional communication interface 53 may also include a standard wired interface and a wireless interface. The memory 54 may be a high-speed RAM memory (Random Access Memory) or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 54 may optionally be at least one storage device located away from the aforementioned processor 51. The processor 51 may be combined with Figure 6 , Figure 7 as well as Figure 8 In the described device, the memory 54 stores computer instructions, and the processor 51 calls the computer instructions stored in the memory 54 to execute the steps of the color temperature estimation method or the white balance adjustment method in any of the above embodiments.
[0096] The communication bus 52 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The communication bus 52 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0097] Among them, the memory 54 may include a volatile memory (English: volatile memory), such as a random access memory (English: random-access memory, abbreviated: RAM); the memory may also include a non-volatile memory (English: non-volatile memory), such as a flash memory (English: flash memory), a hard disk drive (English: hard disk drive, abbreviated: HDD) or a solid-state drive (English: solid-state drive, abbreviated: SSD); the memory 54 may also include a combination of the above types of memory.
[0098] The processor 51 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.
[0099] The processor 51 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0100] In one embodiment, the present application further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the color temperature estimation method and the white balance adjustment method in any of the above embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above types of memories.
[0101] In one embodiment, Fig.10 As shown, a white balance adjustment system is also provided, including a white balance adjustment terminal 102 , an image acquisition device 101 and a calibration terminal 103 .
[0102] The image acquisition device 101 is used to acquire a target image and send it to the white balance adjustment terminal 102 and the calibration terminal 103; the calibration terminal 103 is used to filter out the skin color blocks of the target image, calculate the target estimated color temperature of the skin color blocks, and send the target estimated color temperature to the white balance adjustment terminal 102; the white balance adjustment terminal 102 is used to calculate the white balance gain according to the target estimated color temperature, and perform white balance adjustment on the target image.
[0103] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A white balance adjustment method, characterized in that: The steps include: Acquire a current frame image and identify a face region in the current frame image, wherein the face region is composed of a plurality of blocks; and acquire white balance statistical information of the blocks in the face region, wherein the white balance statistical information includes R, G, and B three-channel response values of the blocks; Calculating a calibration parameter value of each block of the face area, wherein the calibration parameter value is used to calibrate each block according to the R, G, B three-channel response values corresponding to each block; Determine the skin color block interval according to the calibration parameter value, and select the target skin color block from the block; Determine whether the target skin color block exists; if so, calculate the average value of the calibration parameter value of the target skin color block; Substituting the average value of the calibration parameter value of the target skin color block into the calibration color temperature curve to calculate the target estimated color temperature; Calculate a white balance gain according to the target estimated color temperature, and use the white balance gain as a white balance manual gain to adjust the white balance; Specifically, the calibration parameter values include R / G values and B / G values, and each of the blocks corresponds to a unique R / G value and B / G value; Determining the skin color block interval according to the calibration parameter value, and filtering out the target skin color block from the block includes: Based on the R / G values and B / G values of all blocks in the face area, respectively determine the maximum and minimum values of the R / G values and B / G values in the face area to obtain the R / G interval and the B / G interval; Determine a first skin color interval according to the R / G interval and the R / G values of each of the blocks in the face area, and determine a second skin color interval according to the B / G interval and the B / G values of each of the blocks in the face area; If the R / G value of the current block falls within the first skin color interval and the B / G value falls within the second skin color interval, the current block is the target skin color block; The first skin color range and the second skin color range are determined in the following manner: According to the R / G value of each block, the number of blocks falling into each first sub-interval in the R / G interval is counted, and the first sub-interval containing the largest number of blocks is used as the first skin color interval; according to the B / G value of each block, the number of blocks falling into each second sub-interval in the B / G interval is counted, and the second sub-interval containing the largest number of blocks is used as the second skin color interval; or Counting the normal distribution of the R / G value of each block within the R / G interval, and determining the first skin color interval according to the normal distribution, and counting the normal distribution of the B / G value of each block within the B / G interval, and determining the second skin color interval according to the normal distribution; or Select the center value of the R / G interval or the B / G interval, obtain and determine whether the number of blocks within the specified distance accounts for half or more of the total number of blocks based on the distance between the R / G value or the B / G value of each block and the center value. If so, take the interval formed by the difference between the center value and the distance and the sum of the center value and the distance as the skin color interval.
2. The white balance adjustment method according to claim 1, characterized in that: The method further includes: if the target skin color block does not exist, entering the step of determining the skin color block interval according to the calibration parameter value to expand the range of the skin color block interval.
3. The white balance adjustment method according to claim 1, characterized in that: The average value of the calibration parameter value of the target skin color block includes the average value of R / G and the average value of B / G; the calibration color temperature curve includes the R / G-color temperature relationship curve and the B / G-color temperature relationship curve; The step of bringing the average value of the calibration parameter value of the target skin color block into the calibration color temperature curve to calculate the target estimated color temperature comprises: Substituting the average value of R / G into the R / G-color temperature relationship curve to obtain a first estimated color temperature; Substitute the average value of B / G into the B / G-color temperature relationship curve to obtain a second estimated color temperature; and calculate the target estimated color temperature according to the first estimated color temperature and the second estimated color temperature.
4. The white balance adjustment method according to claim 3, characterized in that: The step of calculating the target estimated color temperature according to the first estimated color temperature and the second estimated color temperature comprises: Calculate the difference between the first estimated color temperature and the second estimated color temperature; determine whether the difference is less than a preset threshold; if so, calculate the average of the first estimated color temperature and the second estimated color temperature as the target estimated color temperature; if not, determine whether the current skin color block screening times exceeds a preset maximum number of iterations, if it exceeds the preset maximum number of iterations, calculate the average of the first estimated color temperature and the second estimated color temperature in all iterations as the target estimated color temperature or calculate the average of the second estimated color temperature in all iterations as the target estimated color temperature, if it does not exceed the preset maximum number of iterations, enter the step of determining the skin color block interval according to the calibration parameter value to expand the range of the skin color block interval.
5. The white balance adjustment method according to claim 1, characterized in that: The method further comprises: Obtain the R, G, and B three-channel response values of different skin color blocks at different color temperatures respectively; Calculating the R / G value and the B / G value of each skin color block at each color temperature according to each of the R, G, and B three-channel response values as calibration parameter values of the skin color block; The calibrated color temperature curve is obtained by fitting the calibrated parameter values and the color temperatures corresponding to the calibrated parameter values.
6. A white balance adjustment device, characterized in that: include: A first acquisition module is configured to acquire a current frame image and identify a face region in the current frame image, wherein the face region is composed of a plurality of blocks; and acquire white balance statistical information of the blocks in the face region, wherein the white balance statistical information includes R, G, and B three-channel response values of the blocks; A first calculation module is configured to calculate a calibration parameter value of each block of the face area, wherein the calibration parameter value is used to calibrate each block according to the R, G, B three-channel response values corresponding to each block; A screening module configured to determine the skin color block interval according to the calibration parameter value, and screen out the target skin color block from the block; specifically, the calibration parameter value includes an R / G value and a B / G value, and each of the blocks corresponds to a unique R / G value and a unique B / G value; Determining the skin color block interval according to the calibration parameter value, and screening out the target skin color block from the block includes: determining the maximum and minimum values of the R / G value and the B / G value in the face area based on the R / G value and the B / G value of all the blocks in the face area, respectively, to obtain the R / G interval and the B / G interval; determining the first skin color interval according to the R / G interval and the R / G value of each block in the face area, and determining the second skin color interval according to the B / G interval and the B / G value of each block in the face area; if the R / G value of the current block falls into the first skin color interval and the B / G value falls into the second skin color interval, then the current block is the target skin color block; wherein the first skin color interval and the second skin color interval are determined in the following manner: according to the R / G value of each block, counting the number of blocks falling into each first sub-interval in the R / G interval, and taking the first sub-interval containing the largest number of blocks as the first skin color interval; according to the B / G value of each block, counting the number of blocks falling into each second sub-interval in the B / G interval, and taking the second sub-interval containing the largest number of blocks as the second skin color interval; or counting the normal distribution of the R / G value of each block in the R / G interval, and determining the first skin color interval according to the normal distribution, and counting the normal distribution of the B / G value of each block in the B / G interval, and determining the second skin color interval according to the normal distribution; or selecting the center value of the R / G interval or the B / G interval, obtaining and determining whether the number of blocks within the specified distance accounts for half or more of the total number of blocks according to the distance between the R / G value or the B / G value of each block and the center value, if so, taking the interval consisting of the difference between the center value and the distance, and the sum of the center value and the distance as the skin color interval; A judgment module configured to judge whether the target skin color block exists; if so, calculate the average value of the calibration parameter value of the target skin color block; A second calculation module is configured to bring the average value of the calibration parameter value of the target skin color block into the calibration color temperature curve to calculate the target estimated color temperature; The third calculation module is configured to calculate a white balance gain according to the target estimated color temperature, and use the white balance gain as a white balance manual gain to adjust the white balance.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the white balance adjustment method according to any one of claims 1 to 5.
