White balance adjustment method and device, equipment, storage medium and program product
By segmenting the image into blocks and calculating weight parameters, the problem of inaccurate white point detection in the white balance algorithm is solved, achieving more accurate white balance adjustment and adapting to complex and monochrome scenes.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU ANYKA MICROELECTRONICS CO LTD
- Filing Date
- 2024-10-21
- Publication Date
- 2026-04-21
AI Technical Summary
Existing white balance algorithms have low accuracy in detecting white points in image processing, resulting in color cast in the adjusted image.
By dividing the target image into blocks, the first weight parameters of each image block are determined, including entropy weight, color temperature weight, and quantity weight. Based on these weight parameters, the white balance gain is calculated, and the white balance is adjusted.
It improves the accuracy of white balance adjustment, adapts to white balance effects in complex scenes and large-area monochrome scenes, and enhances the robustness and adaptability of the white balance algorithm.
Smart Images

Figure CN121908149A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a white balance adjustment method, apparatus, device, storage medium, and program product. Background Technology
[0002] White balance is a common processing algorithm used in camera sensors. Most cameras have a built-in automatic white balance (AWB) algorithm. Common AWB algorithms include AWB based on color temperature estimation, perfect reflection, and gray-world method.
[0003] However, current AWB algorithms all suffer from low accuracy in detecting white points in images, leading to color cast in the adjusted image; in other words, the accuracy of the algorithm's white balance correction is low. Therefore, improving the accuracy of white balance correction algorithms is an urgent problem to be solved. Summary of the Invention
[0004] Therefore, it is necessary to provide a white balance adjustment method, apparatus, device, storage medium, and program product that can improve the accuracy of white balance algorithm correction in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a white balance adjustment method. The method includes:
[0006] The target image is divided into blocks to obtain multiple image blocks corresponding to the target image; each image block includes multiple pixels in the target image; a first weight parameter is determined for each image block; the first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions; the white balance gain of the target image is determined according to each first weight parameter; and the white balance is adjusted for the target image according to the white balance gain.
[0007] In one embodiment, determining the white balance gain of the target image based on each first weight parameter includes: for each image block, weighting the channel values of pixels that meet preset conditions in the image block to obtain the channel value data corresponding to the image block; and determining the white balance gain based on the first weight parameter of each image block and the channel value data of each image block.
[0008] In one embodiment, for each image block, the channel values of pixels in the image block that meet preset conditions are weighted to obtain the channel value data corresponding to the image block. This includes: determining a plurality of first pixels in the image block that meet preset channel value conditions; determining second pixels from the plurality of first pixels that meet preset brightness conditions; determining a second weight parameter for each second pixel, the second weight parameter including a brightness weight related to the brightness of the second pixel and a distance weight related to the difference between the color temperature of the second pixel and the standard color temperature; and performing a weighted summation of the channel values of each second pixel according to the second weight parameter to obtain the channel value data corresponding to the image block.
[0009] In one embodiment, determining multiple first pixels in the image block that satisfy a preset channel value condition includes: determining the coordinate values of each pixel in the image block in a color space coordinate system; wherein the horizontal axis of the color space coordinate system represents a first color coordinate value; the first color coordinate value is related to color temperature and increases from small to large to indicate a change in color temperature from low to high; the vertical axis of the color space coordinate system represents a second color coordinate value, which is related to the color rendering index; determining the coordinate value range to which the coordinate value of each pixel belongs; determining the color temperature region range corresponding to each coordinate value range according to a region range correspondence table; wherein the region range correspondence table includes multiple sets of correspondences between candidate color temperature regions and candidate coordinate value ranges; and selecting the pixel corresponding to each color temperature region range as the first pixel.
[0010] In one embodiment, determining the coordinate values of each pixel in the image block in the color space coordinate system includes: for each pixel, calculating the ratio of the R channel value to the G channel value of the pixel to obtain a first ratio; and calculating the ratio of the B channel value to the G channel value of the pixel to obtain a second ratio; calculating the logarithm of the first ratio to obtain a first color coordinate value of the pixel; and calculating the logarithm of the second ratio to obtain a second color coordinate value of the pixel.
[0011] In one embodiment, the process of determining the region range correspondence table includes: establishing the color space coordinate system; determining the positions of multiple white pixels corresponding to different standard color temperatures in the color space coordinate system; fitting the positions of each white pixel in the color space coordinate system to obtain an initial fitted color temperature line; rotating the initial fitted color temperature line by a preset angle to obtain a target fitted color temperature line; and based on the target fitted color temperature line and the positions of each white pixel in the color space coordinate system, calibrating each candidate color temperature region and determining the candidate coordinate value range corresponding to each candidate color temperature region.
[0012] In one embodiment, determining a second pixel that satisfies a preset brightness condition from a plurality of the first pixels includes: selecting a first pixel whose brightness information is within a preset brightness range as the second pixel.
[0013] In one embodiment, determining the second weight parameter of each second pixel includes: determining a reference distance parameter for the color temperature region range corresponding to the second pixel; determining an initial distance parameter based on the reference distance parameter and the second color coordinate value of the second pixel; and obtaining the distance weight of the second pixel based on the initial distance parameter and a first correspondence relationship; wherein the first correspondence relationship is a pre-determined correspondence relationship between multiple sets of different initial distance parameters and different distance weights.
[0014] In one embodiment, determining the second weight parameter of each second pixel includes: determining the brightness weight of the second pixel based on the brightness information of the second pixel and a second correspondence; the second correspondence is a pre-determined correspondence between multiple sets of different brightness information and different brightness weights.
[0015] In one embodiment, determining the white balance gain based on the first weight parameter of each image block and the channel value data of each image block includes: performing a weighted summation process on the channel value data of each image block according to the first weight parameter to obtain a weighted statistical value corresponding to different channels; and determining the white balance gain based on the weighted statistical value corresponding to different channels.
[0016] In one embodiment, determining the white balance gain based on the weighted statistical values corresponding to the different channels includes: determining the maximum value of the weighted statistical value corresponding to each channel; calculating the ratio of the maximum value to the weighted statistical value corresponding to each channel to obtain the target gain value corresponding to each channel; and using each target gain value as the white balance gain.
[0017] In one embodiment, determining the first weight parameter for each image block includes: for each image block, determining the entropy weight based on the U and V components of each pixel in the image block.
[0018] In one embodiment, determining the entropy weight based on the U and V components of each pixel in the image block includes: determining a first entropy weight and a second entropy weight based on the U and V components of each pixel; determining the total entropy weight based on the first entropy weight and the second entropy weight; wherein the first entropy weight is determined based on a two-dimensional chromaticity histogram constructed based on the U and V components of each pixel; and the second entropy weight is determined based on the number of pixels in the image block whose U and V components are within a preset chromaticity threshold range.
[0019] In one embodiment, the process of determining the first entropy weight based on the U and V components of each pixel includes: constructing a two-dimensional chromaticity histogram based on the U and V components of each pixel; calculating the two-dimensional entropy information of the image block based on the two-dimensional chromaticity histogram; and determining the first entropy weight based on the two-dimensional entropy information.
[0020] In one embodiment, determining the first entropy weight based on the two-dimensional entropy information includes: obtaining the first entropy weight based on the two-dimensional entropy information and a third correspondence; the third correspondence is a pre-determined correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information.
[0021] In one embodiment, the process of determining the second entropy weight based on the U component and V component of each pixel includes: determining the number of pixels in the image block whose U component value is less than a preset difference threshold and whose V component value is less than a preset difference threshold based on the U component and V component of each pixel, thereby obtaining the first number of pixels; and determining the second entropy weight based on the first number of pixels.
[0022] In one embodiment, determining the second entropy weight based on the number of first pixels includes: obtaining the second entropy weight based on the number of first pixels and a fourth correspondence; the fourth correspondence is a pre-determined correspondence between multiple sets of different second entropy weights and different numbers of first pixels.
[0023] In one embodiment, determining the entropy weight based on the first entropy weight and the second entropy weight includes: calculating the difference between the first preset value and the second entropy weight to obtain a first candidate weight; calculating the product of the first entropy weight and the first candidate weight to obtain a second candidate weight; and using the sum of the second entropy weight and the second candidate weight as the entropy weight.
[0024] In one embodiment, determining the first weight parameter for each image block includes: for each image block, determining the exposure parameter of the image block; obtaining a fifth correspondence, which is a pre-determined correspondence between multiple sets of different exposure parameters and different color temperature weights; and determining the color temperature weight of the image block based on the exposure parameter and the fifth correspondence.
[0025] In one embodiment, obtaining the fifth correspondence includes: determining the primary color temperature type of the image block; and obtaining a preset correspondence corresponding to the primary color temperature type as the fifth correspondence based on the color temperature type.
[0026] In one embodiment, determining the dominant color temperature type of the image block includes: counting the number of second pixels corresponding to each color temperature region range; and taking the color temperature type of the color temperature region range with the largest number of corresponding second pixels as the dominant color temperature type.
[0027] In one embodiment, determining the first weight parameter of each image block includes: determining the number of the second pixel in the image block; obtaining the quantity weight based on the number of the second pixel and a sixth correspondence; the sixth correspondence is a pre-determined correspondence between the number of different second pixels and different quantity weights.
[0028] In one embodiment, before segmenting the target image, the method further includes: acquiring RAW format image data corresponding to the target image; the image data includes multiple RAW format target pixels; and performing linear interpolation on the channel values of each target pixel to obtain the target image.
[0029] In one embodiment, each target pixel includes a channel value corresponding to an R channel, a G channel, or a B channel; the linear interpolation processing of the channel values of each target pixel includes: for each target pixel, determining the channel values of other pixels within a preset neighborhood of the target pixel; calculating the average value of the channel values corresponding to the first channel of each of the other pixels to obtain a first average value, and using the first average value as the pixel value corresponding to the first channel in the target pixel; calculating the average value of the channel values corresponding to the second channel of each of the other pixels to obtain a second average value, and using the second average value as the pixel value corresponding to the second channel in the target pixel; wherein the first channel and the second channel are channels for missing channel values of the target pixel among the R channel, G channel, and B channel.
[0030] Secondly, this application also provides a white balance adjustment device. The device includes:
[0031] The image segmentation module is used to segment the target image into blocks to obtain multiple image blocks corresponding to the target image; wherein each image block includes multiple pixels in the target image;
[0032] The parameter determination module is used to determine the first weight parameter of each image block; the first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet the preset conditions.
[0033] The gain determination module is used to determine the white balance gain of the target image based on each first weight parameter.
[0034] The image adjustment module is used to perform white balance adjustment processing on the target image according to the white balance gain.
[0035] In one embodiment, the gain determination module is specifically used to: for each image block, perform weighted processing on the channel values of pixels in the image block that meet preset conditions to obtain the channel value data corresponding to the image block; and determine the white balance gain based on the first weight parameter of each image block and the channel value data of each image block.
[0036] In one embodiment, the gain determination module is specifically configured to: determine a plurality of first pixels in the image block that satisfy a preset channel value condition; determine a second pixel from the plurality of first pixels that satisfies a preset brightness condition; determine a second weight parameter for each second pixel, the second weight parameter including a brightness weight related to the brightness of the second pixel and a distance weight related to the difference between the color temperature of the second pixel and the standard color temperature; and perform weighted summation on each channel value of each second pixel according to the second weight parameter to obtain the channel value data corresponding to the image block.
[0037] In one embodiment, the gain determination module is specifically used for: determining the coordinate values of each pixel in the image block in a color space coordinate system; wherein the horizontal axis of the color space coordinate system represents a first color coordinate value; the first color coordinate value is related to the color temperature and increases from small to large to indicate a change in color temperature from low to high; the vertical axis of the color space coordinate system represents a second color coordinate value, which is related to the color rendering index; determining the coordinate value range to which the coordinate value of each pixel belongs; determining the color temperature region range corresponding to each coordinate value range according to a region range correspondence table; wherein the region range correspondence table includes multiple sets of candidate color temperature regions and candidate coordinate value ranges; and taking the pixel corresponding to each color temperature region range as the first pixel.
[0038] In one embodiment, the gain determination module is specifically configured to: for each pixel, calculate the ratio of the R channel value to the G channel value of the pixel to obtain a first ratio; and calculate the ratio of the B channel value to the G channel value of the pixel to obtain a second ratio; calculate the logarithm of the first ratio to obtain a first color coordinate value of the pixel; and calculate the logarithm of the second ratio to obtain a second color coordinate value of the pixel.
[0039] In one embodiment, the gain determination module is specifically used for: establishing the color space coordinate system; determining the positions of multiple white pixels corresponding to different standard color temperatures in the color space coordinate system; fitting the positions of each white pixel in the color space coordinate system to obtain an initial fitted color temperature line; rotating the initial fitted color temperature line by a preset angle to obtain a target fitted color temperature line; and based on the target fitted color temperature line and the positions of each white pixel in the color space coordinate system, calibrating each candidate color temperature region and determining the candidate coordinate value range corresponding to each candidate color temperature region.
[0040] In one embodiment, the gain determination module is specifically used to: take a first pixel whose brightness information is within a preset brightness range as the second pixel.
[0041] In one embodiment, the gain determination module is specifically used to: determine a reference distance parameter for the color temperature region range corresponding to the second pixel; determine an initial distance parameter based on the reference distance parameter and the second color coordinate value of the second pixel; and obtain the distance weight of the second pixel based on the initial distance parameter and a first correspondence relationship; wherein the first correspondence relationship is a pre-determined correspondence relationship between multiple sets of different initial distance parameters and different distance weights.
[0042] In one embodiment, the gain determination module is specifically used to: determine the brightness weight of the second pixel based on the brightness information of the second pixel and the second correspondence; the second correspondence is a pre-determined correspondence between multiple sets of different brightness information and different brightness weights.
[0043] In one embodiment, the gain determination module is specifically used to: perform weighted summation on the channel value data of each image block according to the first weight parameter to obtain the weighted statistical value corresponding to different channels; and determine the white balance gain according to the weighted statistical value corresponding to different channels.
[0044] In one embodiment, the gain determination module is specifically used to: determine the maximum value among the weighted statistical values corresponding to each channel; calculate the ratio of the maximum value to the weighted statistical values corresponding to each channel to obtain the target gain value corresponding to each channel; and use each target gain value as the white balance gain.
[0045] In one embodiment, the parameter determination module is specifically used to: for each image block, determine the entropy weight based on the U component and V component of each pixel in the image block.
[0046] In one embodiment, the parameter determination module is specifically used to: determine a first entropy weight and a second entropy weight based on the U component and V component of each pixel; determine the entropy weight based on the first entropy weight and the second entropy weight; wherein the first entropy weight is determined based on a two-dimensional chromaticity histogram constructed based on the U component and V component of each pixel; and the second entropy weight is determined based on the number of pixels in the image block whose U component and V component are within a preset chromaticity threshold range.
[0047] In one embodiment, the parameter determination module is specifically used to: construct a two-dimensional chromaticity histogram based on the U and V components of each pixel; calculate the two-dimensional entropy information of the image block based on the two-dimensional chromaticity histogram; and determine the first entropy weight based on the two-dimensional entropy information.
[0048] In one embodiment, the parameter determination module is specifically used to: obtain the first entropy weight based on the two-dimensional entropy information and the third correspondence; the third correspondence is a pre-determined correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information.
[0049] In one embodiment, the parameter determination module is specifically used to: determine the number of pixels in the image block whose U component value is less than a preset difference threshold and whose V component value is less than a preset difference threshold based on the U component and V component of each pixel, thereby obtaining a first pixel count; and determine the second entropy weight based on the first pixel count.
[0050] In one embodiment, the parameter determination module is specifically used to: obtain the second entropy weight based on the number of first pixels and the fourth correspondence; the fourth correspondence is a pre-determined correspondence between multiple sets of different second entropy weights and different numbers of first pixels.
[0051] In one embodiment, the parameter determination module is specifically used to: calculate the difference between a first preset value and the second entropy weight to obtain a first candidate weight; calculate the product of the first entropy weight and the first candidate weight to obtain a second candidate weight; and use the sum of the second entropy weight and the second candidate weight as the entropy weight.
[0052] In one embodiment, the parameter determination module is specifically used for: determining the exposure parameters of each image block; obtaining a fifth correspondence, which is a pre-determined correspondence between multiple sets of different exposure parameters and different color temperature weights; and determining the color temperature weight of the image block based on the exposure parameters and the fifth correspondence.
[0053] In one embodiment, the parameter determination module: determines the primary color temperature type of the image block; and obtains a preset correspondence relationship corresponding to the primary color temperature type as the fifth correspondence relationship based on the color temperature type.
[0054] In one embodiment, determining the dominant color temperature type of the image block includes: counting the number of second pixels corresponding to each color temperature region range; and taking the color temperature type of the color temperature region range with the largest number of corresponding second pixels as the dominant color temperature type.
[0055] In one embodiment, the parameter determination module: determines the number of the second pixel in the image block; obtains the quantity weight based on the number of the second pixel and a sixth correspondence; the sixth correspondence is a pre-determined correspondence between the number of different second pixels and different quantity weights.
[0056] In one embodiment, the device further includes a format processing module for: acquiring RAW format image data corresponding to the target image before performing block processing on the target image; the image data includes multiple target pixels in RAW format; and performing linear interpolation processing on the channel values of each target pixel to obtain the target image.
[0057] In one embodiment, each target pixel includes a channel value corresponding to an R channel, a G channel, or a B channel; the format processing module is specifically used for: for each target pixel, determining the channel values of other pixels within a preset neighborhood of the target pixel; calculating the average value of the channel values corresponding to the first channel of each of the other pixels to obtain a first average value, and using the first average value as the pixel value corresponding to the first channel in the target pixel; calculating the average value of the channel values corresponding to the second channel of each of the other pixels to obtain a second average value, and using the second average value as the pixel value corresponding to the second channel in the target pixel; wherein the first channel and the second channel are channels for missing channel values of the target pixel among the R channel, G channel, and B channel.
[0058] Thirdly, this application also provides a computer device, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the method described in any of the first aspects above.
[0059] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in any one of the first aspects above.
[0060] Fifthly, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the method described in any one of the first aspects above.
[0061] The aforementioned white balance adjustment method, apparatus, device, storage medium, and program product divide a target image into blocks to obtain multiple image blocks corresponding to the target image. Each image block includes multiple pixels in the target image. A first weight parameter is determined for each image block. The first weight parameter includes an entropy weight related to the chroma of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions. Based on each first weight parameter, the white balance gain of the target image is determined. White balance adjustment processing is then performed on the target image based on the white balance gain. In this way, by determining the chroma-related entropy weight, the light source color temperature-related color temperature weight, and the quantity weight related to the number of pixels meeting preset conditions for each image block, the influence of large areas of monochromatic pixels, pixels that do not meet preset conditions, and pixels with a target color temperature spectral response under a specific light source on the overall white balance gain calculation of the target image can be eliminated. Based on this, white balance adjustment processing is performed, improving the accuracy of the white balance adjustment processing. Attached Figure Description
[0062] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0063] Figure 1 This is a flowchart illustrating a white balance adjustment method in one embodiment;
[0064] Figure 2 This is a schematic diagram of image segmentation in one embodiment;
[0065] Figure 3 This is a flowchart illustrating the linear interpolation process in one embodiment;
[0066] Figure 4 This is a schematic diagram of the pixel distribution within a preset neighborhood in one embodiment;
[0067] Figure 5 This is a flowchart illustrating the process of determining white balance gain in one embodiment;
[0068] Figure 6 This is a flowchart illustrating the process of determining channel value data in one embodiment;
[0069] Figure 7 This is a flowchart illustrating the process of determining the first pixel in one embodiment;
[0070] Figure 8 This is a flowchart illustrating the process of determining a region range mapping table in one embodiment;
[0071] Figure 9 This is a schematic diagram of the distribution of white pixels in a color space coordinate system in one embodiment;
[0072] Figure 10 This is a flowchart illustrating the process of determining the distance weight of the second pixel in one embodiment;
[0073] Figure 11 This is a distance-weighted diagram in one embodiment;
[0074] Figure 12 This is a schematic diagram of the first correspondence function curve in one embodiment;
[0075] Figure 13 This is a schematic diagram of the second correspondence function curve in one embodiment;
[0076] Figure 14 This is a flowchart illustrating the process of determining the first entropy weight in one embodiment;
[0077] Figure 15 This is a schematic diagram of the third correspondence function curve in one embodiment;
[0078] Figure 16 This is a schematic diagram of the fourth correspondence function curve in one embodiment;
[0079] Figure 17 This is a flowchart illustrating the process of determining color temperature weights in one embodiment;
[0080] Figure 18 This is a schematic diagram illustrating the correspondence between exposure parameters and color temperature weights in one embodiment;
[0081] Figure 19 This is a schematic diagram illustrating the correspondence between another exposure parameter and color temperature weight in one embodiment;
[0082] Figure 20 This is a schematic diagram illustrating the correspondence between another exposure parameter and color temperature weight in one embodiment;
[0083] Figure 21 This is a schematic diagram illustrating the correspondence between another exposure parameter and color temperature weight in one embodiment;
[0084] Figure 22 This is a schematic diagram of the sixth relational function curve in one embodiment;
[0085] Figure 23 This is a flowchart illustrating the process of determining white balance gain in one embodiment;
[0086] Figure 24 This is a schematic diagram of the image processing flow in one embodiment;
[0087] Figure 25 This is a structural block diagram of a white balance adjustment device in one embodiment;
[0088] Figure 26 This is an internal structural diagram of a computer device in one embodiment;
[0089] Figure 27 This is an internal structural diagram of another computer device in one embodiment. Detailed Implementation
[0090] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the specific embodiments of this application will be described in detail below with reference to the accompanying drawings. It should be understood that many specific details are set forth in the following description in order to provide a full understanding of this application, but this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of this application. Therefore, this application is not limited to the specific embodiments disclosed below.
[0091] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0092] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0093] It is understandable that "at least one" refers to one or more, and "multiple" refers to two or more. "At least a part of an element" refers to part or all of an element.
[0094] When used herein, the singular forms of “a,” “an,” and “the” may also include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms “comprising / including” or “having,” etc., specify the presence of the stated features, wholes, steps, operations, components, parts, or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts, or combinations thereof. Meanwhile, the term “and / or” as used in this specification includes any and all combinations of the associated listed items.
[0095] The human eye possesses color constancy, meaning it can perceive the true color of an object even under light sources of different color temperatures. Camera sensors, however, lack this capability. For example, white objects photographed under low color temperature light appear reddish, while those photographed under high color temperature light appear bluish. To enable cameras to exhibit color constancy like the human eye, it's necessary to eliminate color casts caused by the light source; this process is called white balance.
[0096] Most cameras have a built-in Automatic White Balance (AWB) algorithm. Common AWB algorithms include the gray-world method, perfect reflection method, AWB algorithm based on color temperature estimation, and AWB algorithm based on deep learning. However, due to environmental and other factors, the accuracy of each algorithm is relatively low.
[0097] In view of this, the embodiments of this application provide a white balance adjustment method, which can improve the accuracy of white balance and adapt to the white balance effect in complex scenes and large-area monochrome scenes. The AWB algorithm proposed in this application has high robustness and good adaptability.
[0098] It should be noted that the white balance adjustment method provided in this application can be implemented by a white balance adjustment device, which can be implemented as part or all of an electronic device through software, hardware, or a combination of software and hardware. The electronic device can be, but is not limited to, various personal computers, laptops, smartphones, tablets, servers, etc., and the server can be a standalone server or a server cluster composed of multiple servers. The following description uses the application of this method to an electronic device as an example.
[0099] In one embodiment, such as Figure 1 As shown, a white balance adjustment method is provided, including the following steps:
[0100] Step 101: Divide the target image into blocks to obtain multiple image blocks corresponding to the target image. Each image block includes multiple pixels in the target image.
[0101] By processing in blocks, it is easier to filter and process each pixel more efficiently in the future.
[0102] Optionally, the target image is in Raw format.
[0103] For example, the entire image with a resolution of row*col is divided into... Image patches, of which , If the parameters are configurable, then each image block can include There are 100 pixels. Here, row refers to the height of the image, and col refers to the width of the image.
[0104] In related technologies, when calculating the statistical values of the RGB components of each block, the RGB components of each pixel after linear interpolation in that block are directly added together and the average value is calculated. Then, the average RGB value of the block is used to determine whether it belongs to the white block of the corresponding color temperature. Although the average value obtained by this method has good noise resistance, this average value may cause a mismatch between the estimated light source and the actual light source for some blocks, as some colored objects may also have white pixel characteristics under certain light sources. For example, under fluorescent lights, if a block contains a part of green leaves and a part of white wall, and the average of the RGB components of the n*m pixels in that block is simply calculated, the calculated data will fall into the white area range of fluorescent lights. This leads to inaccurate estimation of the light source, resulting in an excessively large white balance gain (Bgain), and the image will appear bluish. Therefore, the embodiments of this application perform subsequent pixel point statistics and weight determination based on image blocks.
[0105] For example, Figure 2 The diagram illustrates dividing the target image into n*m image blocks according to row*col. It can be understood that... Figure 2 This is for illustrative purposes only and does not represent the actual proportions.
[0106] Step 102: Determine the first weight parameter for each image block. The first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions.
[0107] Entropy weights are related to the chroma of image patches, thus characterizing whether an image patch is texture-rich or textureless. The richer the content of an image patch, the greater its entropy. Determining the magnitude of entropy weights helps mitigate misclassification caused by large monochrome patches. Since a small entropy might indicate a patch that is either a non-textured region with a large concentration of white dots or a non-textured region without a concentration of white dots, it is also necessary to consider the cases of non-textured white dot concentration patches and non-textured non-white dot concentration patches.
[0108] Color temperature weighting is related to the color temperature of the light source of the image patch. This allows us to determine the light source of the image patch, which helps in adjusting the white balance in the direction of the corresponding light source.
[0109] Pixels that meet preset conditions can be classified as white pixels. By determining the weights of these white pixels, the proportion of white pixels in an image patch can be represented, helping to eliminate the influence of large areas of color blocks.
[0110] Step 103: Determine the white balance gain of the target image based on each first weight parameter.
[0111] The pixel values of each image block can be weighted according to the first weight parameters to determine the white balance gain of the target image.
[0112] Step 104: Perform white balance adjustment processing on the target image based on the white balance gain.
[0113] The aforementioned white balance adjustment method divides the target image into blocks, obtaining multiple image blocks corresponding to the target image. Each image block includes multiple pixels in the target image. A first weight parameter is determined for each image block. This first weight parameter includes an entropy weight related to the chroma of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions. Based on these first weight parameters, the white balance gain of the target image is determined. White balance adjustment is then performed on the target image based on this white balance gain. By determining the entropy weight related to the chroma, the color temperature weight related to the light source color temperature, and the quantity weight related to the number of pixels meeting preset conditions for each image block, the influence of large areas of monochromatic pixels, pixels that do not meet preset conditions, and pixels with a target color temperature spectral response under a specific light source on the overall white balance gain calculation of the target image can be eliminated. Based on this, white balance adjustment is performed, improving the accuracy of the white balance adjustment process.
[0114] In one embodiment, before segmenting the target image, the method further includes: acquiring RAW format image data corresponding to the target image; the image data includes multiple RAW format target pixels. Linear interpolation is then performed on the channel values of each target pixel to obtain the target image.
[0115] The captured image may be output as RAW format image data, and it is necessary to obtain the complete RGB format target image based on this.
[0116] For example, raw RAW format image data is acquired using a CMOS image sensor. Here, each target pixel includes the channel value corresponding to the R, G, or B channels. That is, each target pixel includes a single-channel pixel value. To obtain a complete RGB format target image, the channel values of each pixel need to be supplemented to generate the channel values of the two missing channel components for each CFA pixel, in order to reduce noise interference while preserving color temperature information.
[0117] For example, if a target pixel includes the R channel value, then the G and B channel values of that target pixel need to be determined based on the channel values of other target pixels surrounding that target pixel.
[0118] Please refer to Figure 3 This diagram illustrates a linear interpolation process according to an embodiment of this application. The linear interpolation process is performed on the channel values of each target pixel, including:
[0119] Step 301: For each target pixel, determine the channel values of other pixels within the preset neighborhood of the target pixel.
[0120] Optionally, the preset neighborhood can be a 5x5 neighborhood. Of course, the size of the preset neighborhood can also be determined according to actual needs.
[0121] It is understandable that other target pixels located within the preset neighborhood, except for the target pixel being processed, are all treated as other pixels.
[0122] Step 302: Calculate the average value of the channel value corresponding to the first channel of each other pixel point to obtain the first average value, and use the first average value as the pixel value corresponding to the first channel in the target pixel point.
[0123] Step 303: Calculate the average value of the channel value corresponding to the second channel of each other pixel point to obtain the second average value, and use the second average value as the pixel value corresponding to the second channel in the target pixel point.
[0124] Among them, the first channel and the second channel are the channels for missing channel values of target pixels in the R channel, G channel and B channel.
[0125] Optionally, the average value of the third channel value of the target pixel and all other pixels in the preset neighborhood of the target pixel is calculated as the pixel value corresponding to the third channel of the target pixel. Here, the third channel refers to the channel where the target pixel does not lack channel values.
[0126] For example, for each target pixel, it is taken as the center pixel within a preset neighborhood, and the average R / G / B values of other pixels within the preset neighborhood are taken. For instance, the average R / G / B values of other pixels within a 5x5 adjacent area are used as the RGB value of the target pixel for statistical analysis. Figure 4 A schematic diagram of pixel distribution within a preset neighborhood is shown. For the boundary pixels around the image (2 rows high, 2 rows low, 2 columns left, and 2 columns right), the boundary pixels can be copied to replace the missing RAW data.
[0127] For G43 (Gb) pixels:
[0128] G_avg = (G43+G32+G34+G52+G54)*51 / 256;
[0129] R_avg = (R31+R33+R35+R51+R53+R55)*43 / 256;
[0130] B_avg = (B22+B24+B42+B44+B62+B64)*43 / 256;
[0131] For G34(Gr) pixels:
[0132] G_avg = (G34+G23+G25+G43+G45)*51 / 256;
[0133] R_avg = (R13+R15+R33+R35+R53+R55)*43 / 256;
[0134] B_avg = (B22+B24+B26+B42+B44+B46)*43 / 256;
[0135] For pixel R33(R):
[0136] G_avg = (G23+G32+G34+G43) / 4;
[0137] R_avg = (R33+R13+R31+R35+R53)*51 / 256;
[0138] B_avg = (B22+B24+B42+B44) / 4;
[0139] For pixel B44(B):
[0140] G_avg = (G34+G43+G45+G54) / 4;
[0141] R_avg = (R33+R35+R53+R55) / 4;
[0142] B_avg = (B44+B24+B42+B46+B64)*51 / 256.
[0143] G_avg is the average value of the center pixel in the preset neighborhood of the G channel; R_avg is the average value of the center pixel in the preset neighborhood of the R channel; B_avg is the average value of the center pixel in the preset neighborhood of the B channel.
[0144] Based on this, a complete RGB format target image can be obtained quickly and accurately. Subsequent steps involve determining weights and adjusting white balance based on the RGB format target image.
[0145] In one embodiment, such as Figure 5 This illustration shows a flowchart of a method for determining white balance gain according to an embodiment of this application. The method involves determining the white balance gain of a target image based on various first weight parameters, including:
[0146] Step 501: For each image block, the channel values of the pixels that meet the preset conditions in the image block are weighted to obtain the channel value data corresponding to the image block.
[0147] Step 502: Determine the white balance gain based on the first weight parameter of each image block and the channel value data of each image block.
[0148] Therefore, the process of determining white balance gain mainly involves the first weight parameter and channel value data of each image block.
[0149] As mentioned above, pixels that meet the preset conditions are white pixels. Therefore, based on the channel value data and the first weight parameter, large areas of color blocks can be accurately corrected.
[0150] First, the process of determining the channel value data corresponding to the image block will be explained.
[0151] In one embodiment, such as Figure 6 This illustration shows a flowchart of a method for determining channel value data according to an embodiment of this application. For each image block, the channel values of pixels in the image block that meet preset conditions are weighted to obtain the channel value data corresponding to the image block, including:
[0152] Step 601: Determine multiple first pixels in the image block that satisfy the preset channel value conditions.
[0153] Among them, the first pixel that meets the preset channel value condition can be a pixel that falls within the range of white pixels.
[0154] Step 602: Determine the second pixel that meets the preset brightness condition from the multiple first pixel points.
[0155] In this process, by setting preset brightness conditions, pixels that are too dark or too bright are excluded from all first pixels.
[0156] Step 603: Determine the second weight parameters for each second pixel. The second weight parameters include a brightness weight related to the brightness of the second pixel and a distance weight related to the difference between the color temperature of the second pixel and the standard color temperature.
[0157] In calculating the distance weight, the color coordinates of the white pixel under the standard color temperature can be used to represent the standard color temperature. The distance weight is obtained by calculating the difference between the color temperature of the second pixel and the color coordinates of the white pixel under the standard color temperature.
[0158] By determining brightness weights and distance weights, the accuracy of channel value statistics for each pixel can be improved.
[0159] Step 604: Based on the second weight parameter, perform weighted summation on the channel values of each second pixel to obtain the channel value data corresponding to the image block.
[0160] Please refer to Figure 7 This document illustrates a flowchart of a process for determining a first pixel point according to an embodiment of this application. The process involves determining multiple first pixel points in an image block that satisfy a preset channel value condition, including:
[0161] Step 701: Determine the coordinate values of each pixel in the image block in the color space coordinate system.
[0162] In this color space coordinate system, the horizontal axis represents the first color coordinate value; the first color coordinate value is related to the color temperature and increases from small to large to indicate a change in color temperature from low to high; the vertical axis represents the second color coordinate value, which is related to the color rendering index.
[0163] For example, determining the coordinates of each pixel in an image patch in a color space coordinate system includes:
[0164] For each pixel, calculate the ratio of its R channel value to its G channel value to obtain the first ratio: R / G; and calculate the ratio of its B channel value to its G channel value to obtain the second ratio: B / G. Calculate the logarithm of the first ratio to obtain the first color coordinate value of the pixel, which is also the color temperature value of the pixel: log2(R / G); and calculate the logarithm of the second ratio to obtain the second color coordinate value of the pixel, which is also the color rendering index of the pixel: log2(B / G).
[0165] If a color space coordinate system is established using G / R and G / B, the system will exhibit significant shifts under different gain conditions due to noise in low-light environments. This necessitates pre-calibrating the white area range at different color temperatures for each gain. While using an R / GB / G color space coordinate system maintains a relatively constant center position for the white point's location at each color temperature, the blackbody radiation curve in this system approximates a hyperbola, making the calculation of the distance from the white point weight to the blackbody radiation curve complex. Furthermore, since the G component in raw data is generally larger than the R and B components, when calculating the two-dimensional entropy of a pixel in the R / GB / G color space coordinate system, R / GB / G values are all less than 1, resulting in insufficient discrimination in the two-dimensional chromaticity histogram. For example, when establishing a color space coordinate system using G / R and G / B, under high gain, the positions of each grayscale color card of the 24-color card in the coordinate system are more dispersed and offset than under low gain; when establishing a color space coordinate system using R / GB / G, under various gain conditions, the positions of each grayscale color card of the 24-color card in the coordinate system are relatively concentrated, and the differentiation is not obvious.
[0166] The R / G and B / G distributions of white pixels at some typical color temperatures were pre-calibrated through experiments, establishing a mapping relationship between scene color temperature and R / G and B / G. Since this mapping relationship also applies in the log domain, this embodiment calculates the average value of the R / G and B values of each pixel in a preset neighborhood of 5*5, and establishes a new color space coordinate system with log2(R / G) and log2(B / G) as the horizontal and vertical axes, respectively.
[0167] In the color space coordinate system, when calculating the two-dimensional entropy of a pixel corresponding to its image patch, R / GB / G are all less than 1. According to the properties of the logarithmic function, the logarithmic function can amplify the differences in the range of 0 to 1, resulting in significant differentiation in the calculation of the two-dimensional chromaticity histogram.
[0168] Step 702: Determine the range of coordinate values to which the coordinate values of each pixel belong.
[0169] Step 703: Determine the color temperature region range corresponding to each coordinate value range according to the region range correspondence table. The region range correspondence table includes the correspondence between multiple candidate color temperature regions and candidate coordinate value ranges.
[0170] For example, such as Figure 8 A flowchart illustrating the process of determining a regional range correspondence table is shown. The process of determining the regional range correspondence table includes:
[0171] Step 801: Establish a color space coordinate system.
[0172] This involves establishing a color space coordinate system with the horizontal axis as log2(R / G) and the vertical axis as log2(B / G).
[0173] Step 802: Determine the positions of multiple white pixels corresponding to different standard color temperatures in the color space coordinate system.
[0174] Here, white pixels refer to white points in white balance, meaning pixels that are equal in all three channels after white balance across various color temperatures. These white pixels could be, for example, pixels corresponding to a white wall or a gray wall, etc., though not all examples are provided here.
[0175] Multiple standard color temperatures can be predetermined to represent light sources of different standards. Furthermore, multiple white pixels can be determined at each standard color temperature, forming corresponding white pixel regions.
[0176] For a given standard color temperature, the values of log2(R / G) and log2(B / G) in an image are fixed within a certain range. Therefore, the position of the white pixel under each standard light source in the color space coordinate system can be determined.
[0177] Step 803: Fit the coordinates of each white pixel in the color space coordinate system to obtain the initial fitted color temperature line.
[0178] Step 804: Rotate the initial fitted color temperature line by a preset angle to obtain the target fitted color temperature line.
[0179] Fit a straight line to each white pixel at each calibrated color temperature to obtain initial fitted color temperature lines. Each initial fitted color temperature line makes an angle θ with the horizontal axis of the logarithmic coordinate system. Rotate the coordinate system according to the following formula to obtain the target fitted color temperature line:
[0180]
[0181] x represents the horizontal axis data of the initial fitted color temperature line, and y represents the vertical axis data of the initial fitted color temperature line; X represents the horizontal axis data of the target fitted color temperature line, and Y represents the vertical axis data of the target fitted color temperature line.
[0182] In the color space coordinate system of this application embodiment, the color temperature curve is converted into a straight line, and the white point area under each standard color temperature is approximately a rectangle. The horizontal axis of the color space coordinate system is the first color coordinate value, which is only related to the color temperature. The value from small to large indicates that the color temperature changes from low to high. The vertical axis of the color space coordinate system represents the second color coordinate value of the pixel, which is only related to the color rendering index.
[0183] White pixels with different color temperatures but similar color rendering indices are distributed near a target fitted color temperature line in this color space coordinate system. White pixels with similar color temperatures but different color rendering indices are distributed along a vertical straight line in this color space coordinate system. This method is well-suited for framing white pixels with different color spectral density.
[0184] Step 805: Based on the target fitted color temperature line and the position of each white pixel in the color space coordinate system, mark each candidate color temperature region and determine the range of candidate coordinate values corresponding to each candidate color temperature region.
[0185] For example, such as Figure 9 This diagram illustrates the distribution of white pixels at different standard color temperatures in a color space coordinate system. H, TL84, D65, etc., are exemplary names of standard color temperatures, and from left to right represent the common white region ranges for low and high color temperatures, respectively.
[0186] In this embodiment, a color space coordinate system is established using log2(R / G)-log2(B / G). On one hand, the logarithmic function expands the separation of values less than 1, solving the problem of insufficient differentiation of certain colored objects in a two-dimensional histogram. On the other hand, in this color space coordinate system, the blackbody radiation curve approximates a straight line, facilitating the calculation of distance weights. Furthermore, for image acquisition devices with the same model image sensor, lens, and IRCUT, manufacturing inconsistencies lead to differences in white point distribution under the same color temperature light source. When the white point distribution difference is large, the calculated white balance gain differs significantly when using the same white balance color temperature rectangle, affecting the consistency of the image acquisition devices. In this color space coordinate system, the white point rectangle for each color temperature can be determined based on the GoldenSample, and then a new white point rectangle is determined based on the offset of different devices in this coordinate system. That is, the consistency problem of the optical path composed of the same model image sensor, lens, and IRCUT is reduced by shifting the white point rectangle.
[0187] Step 704: Select the pixel corresponding to each color temperature range as the first pixel.
[0188] Each pixel in each image block is determined to fall within a pre-planned color temperature range corresponding to a standard color temperature. If a pixel falls within a color temperature range, it is identified as the first pixel. Pixels that do not fall within a color temperature range are excluded. In this way, for each image block, white pixels are selected as the first pixels.
[0189] In one embodiment, determining a second pixel that satisfies a preset brightness condition from a plurality of first pixels includes: selecting first pixels whose brightness information is within a preset brightness range as second pixels.
[0190] For example, the preset brightness range is greater than MinY and less than MaxY. For instance, if MinY and MaxY are set to 3 and 235 respectively, the first pixel with brightness within this range is used as the second pixel, and other first pixels are excluded. In this way, the influence of noise from overly dark pixels and the influence of oversaturation from overly bright pixels can be eliminated.
[0191] In one embodiment, such as Figure 10 A flowchart illustrating the process of determining the distance weight of the second pixel is shown. The determination of the second weight parameters for each second pixel includes:
[0192] Step 1001: Determine the reference distance parameter for the color temperature range corresponding to the second pixel.
[0193] When calculating the distance weight of the second pixel at each color temperature, the distance from the ordinate of the center point of each color temperature rectangle to the target fitted color temperature line within the color space coordinate system can be used as a reference distance parameter for subsequent distance weight calculations. Essentially, the rectangle defines the color temperature region corresponding to that color temperature.
[0194] Specifically, if the center coordinates of a certain color temperature rectangle are above the corresponding target fitted color temperature line, then the reference distance parameter of the color temperature region is positive; if the center coordinates of a certain color temperature rectangle are below the corresponding target fitted color temperature line, then the reference distance parameter of the color temperature region is negative.
[0195] When the second pixel falls within the corresponding color temperature range, the distance of the second pixel relative to the target fitted color temperature line is calculated based on the reference distance parameter of that color temperature range. In other words, it's equivalent to symmetrically processing the bounding boxes of all color temperatures with the target fitted color temperature line as the reference.
[0196] Step 1002: Determine the initial distance parameter based on the reference distance parameter and the second color coordinate value of the second pixel.
[0197] For example, such as Figure 11 A distance-weighted calculation diagram is shown. When calculating the distance weight of a second pixel that falls within the rectangle of standard color temperature A, the reference distance parameter d2 of standard color temperature A is subtracted from the ordinate log2(B / G) of the second pixel, resulting in the initial distance parameter D = abs((log2(B / G)) - (d2)). The distance weight of the pixel is then calculated based on this distance D. It is understandable that there may be cases where the target fitted color temperature line coincides with the horizontal axis, for example... Figure 10 In the diagram, the target fitted color temperature line corresponding to the color temperature range of the standard color temperature H coincides with the horizontal axis.
[0198] Step 1003: Obtain the distance weight of the second pixel based on the initial distance parameters and the first correspondence. The first correspondence is a pre-determined correspondence between multiple sets of different initial distance parameters and different distance weights.
[0199] For example, the first correspondence function curve formed by the correspondence between multiple sets of different initial distance parameters and different distance weights is as follows: Figure 12 As shown, Figure 12 The horizontal axis D represents the initial distance parameter, and the vertical axis W... Di This represents the distance weights, where D1 and D2 are two preset distance thresholds. Optionally, the initial distance parameters must be valid within the range of D1 and D2 to obtain the corresponding distance weights.
[0200] In this way, the first correspondence can be queried based on the initial distance parameters of each second pixel to obtain the distance weight corresponding to each second pixel.
[0201] In one embodiment, determining the second weight parameter of each second pixel includes: determining the brightness weight of the second pixel based on the brightness information of the second pixel and the second correspondence; the second correspondence is a pre-determined correspondence between multiple sets of different brightness information and different brightness weights.
[0202] Furthermore, the brightness weight of each second pixel is determined based on its corresponding brightness information. For example, assuming the raw data is 10-bit input, then for each pixel:
[0203] R = R _linear_inter_demosa_avg >>2;
[0204] G = G _linear_inter_demosa_avg >>2;
[0205] B = B _linear_inter_demosa_avg >>2;
[0206] The brightness information corresponding to each second pixel is:
[0207] Y = (77*R + 150*G + 29*B+128)>>8.
[0208] Among them, R _linear_inter_demosa_avg G _linear_inter_demosa_avg B _linear_inter_demosa_avg This represents the average value of a single pixel in the Raw data domain after linear interpolation within a preset neighborhood. >> indicates a right shift operation; for example, >>2 means divide by 2. 2 >>7 means divide by 27 .
[0209] For example, the second correspondence function curve formed by the correspondence between multiple sets of different brightness information and different brightness weights is as follows: Figure 13 As shown, Figure 13 The horizontal axis Y represents brightness information, and the vertical axis W... Yi This indicates the brightness weight.
[0210] In one embodiment, the channel values of each second pixel are weighted and summed according to the second weight parameter to obtain the channel value data corresponding to the image block, including:
[0211]
[0212] in, , , These are the channel value data corresponding to the R, G, and B channels of the image block, respectively. R represents the total number of second pixels. i For the i-th second pixel, The distance weight for the i-th second pixel is... Let be the brightness weight of the i-th second pixel.
[0213] In addition, it can also output the number of second pixels in each image block at each standard color temperature: The subscript CT indicates different standard color temperatures, for example... This indicates the number of second pixels in a given image patch at standard color temperature A.
[0214] The process of determining the first weight parameter of an image patch is explained below.
[0215] First, the process of determining the entropy weight will be explained.
[0216] In one embodiment, determining the first weight parameter for each image block includes: for each image block, determining the entropy weight based on the U and V components of each pixel in the image block.
[0217] The entropy weight of an image patch characterizes whether its content is texture-rich or textureless; the richer the content of the image patch, the larger its entropy weight. Determining the magnitude of the entropy weight reduces misjudgments caused by large monochrome patches. Since the U and V components of a pixel are related to color, i.e., to the texture richness of the image patch, the entropy weight is determined based on the U and V components of each pixel in the image patch.
[0218] Optionally, for each image block, the influence of overly dark and overly bright pixels is eliminated based on the brightness information of each pixel in the image block. That is, the entropy weight of the image block is determined only based on the U and V components of the pixels whose brightness information is within a preset brightness range.
[0219] In one embodiment, determining the entropy weight based on the U and V components of each pixel in the image block includes: determining a first entropy weight and a second entropy weight based on the U and V components of each pixel; and determining the entropy weight based on the first entropy weight and the second entropy weight.
[0220] The first entropy weight is determined based on a two-dimensional chromaticity histogram constructed from the U and V components of each pixel. The second entropy weight is determined based on the number of pixels in the image patch whose U and V components fall within a preset chromaticity threshold range. In this way, the image content texture is described more accurately through two entropy weights in different directions.
[0221] In one embodiment, such as Figure 14 A flowchart illustrating the determination of the first entropy weights is shown. The process of determining the first entropy weights based on the U and V components of each pixel includes:
[0222] Step 1401: Construct a two-dimensional chromaticity histogram based on the U and V components of each pixel.
[0223] The range of U and V components is [0, 255]. The calculation formulas for U and V components are as follows:
[0224] R = R_ linear_inter_demosa_avg >>2;
[0225] G = G_ linear_inter_demosa_avg >>2;
[0226] B = B_ linear_inter_demosa_avg >>2;
[0227] U = (-43*R - 85*G + 128*B+32768)>>8;
[0228] V = (128*R - 107*G -21*B+32768)>>8.
[0229] In this way, a two-dimensional chromaticity histogram can be established based on the UV components.
[0230] Step 1402: Calculate the two-dimensional entropy information of the image patch based on the two-dimensional chromaticity histogram.
[0231] For example, the two-dimensional entropy information H of an image patch is calculated based on a two-dimensional chromaticity histogram as follows:
[0232] ;
[0233] In the above formula, Hist(u,v) counts the number of pixels with u and v components, which are the U and V values calculated by the above formula, respectively. The values of the u and v components range from 0 to 255. For example, if there are 32 pixels with u=64 and v=72 in a certain image patch, then Hist(64,72)=32. Furthermore, m is the number of pixels horizontally in the image patch, and n is the number of pixels vertically in the image patch.
[0234] Step 1403: Determine the weight of the first entropy based on the two-dimensional entropy information.
[0235] In one embodiment, determining the first entropy weight based on two-dimensional entropy information includes: obtaining the first entropy weight based on the two-dimensional entropy information and a third correspondence; the third correspondence is a pre-determined correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information.
[0236] For example, the third correspondence function curve formed by the correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information is as follows: Figure 15 The above, Figure 15 The horizontal axis H represents two-dimensional entropy information, and the vertical axis Wh represents the first entropy weight. H1 and H2 are two entropy thresholds.
[0237] In one embodiment, the process of determining the second entropy weight based on the U and V components of each pixel includes: determining the number of pixels in the image block whose U component value differs from 128 by a preset difference threshold and whose V component value differs from 128 by a preset difference threshold, based on the U and V components of each pixel, to obtain the first pixel count. The second entropy weight is then determined based on the first pixel count.
[0238] The preset difference threshold can be determined according to the actual situation. If the difference between the U component value and 128 is less than the preset difference threshold, it means that the U component value is around 128. Similarly, if the difference between the V component value and 128 is less than the preset difference threshold, it means that the V component value is around 128. That is, by determining the number of pixels falling in the vicinity of (128, 128), the number of the first pixel is obtained.
[0239] For example, the preset difference threshold can be determined based on the condition that the number of pixels falling near (128, 128) in the two-dimensional chromaticity histogram accounts for 80% to 90% of the total number of pixels in the image block.
[0240] For example, the number of pixels whose U and V components fall within the range of the following formula is the number of the first pixel:
[0241]
[0242] NumPer is a reference threshold that can be set to a value that suits the situation. For example, you can set it to 0.1.
[0243] In one embodiment, determining the second entropy weight based on the number of first pixels includes: obtaining the second entropy weight based on the number of first pixels and a fourth correspondence; the fourth correspondence is a pre-determined correspondence between multiple sets of different second entropy weights and different numbers of first pixels.
[0244] For example, the fourth correspondence function curve formed by the correspondence between multiple sets of different second entropy weights and different numbers of first pixels is as follows: Figure 16 As shown, the horizontal axis NumCnt represents the number of first pixels, and the vertical axis Ws represents the second entropy weight. NumCnt1 and NumCnt2 are two thresholds.
[0245] In one embodiment, determining the entropy weight based on the first entropy weight and the second entropy weight includes:
[0246] Calculate the difference between the first preset value and the second entropy weight to obtain the first candidate weight; calculate the product of the first entropy weight and the first candidate weight to obtain the second candidate weight; use the sum of the second entropy weight and the second candidate weight as the entropy weight.
[0247] Optionally, the first preset value is 1. Based on this, the entropy weight W hs = Ws + Wh * (1 - Ws).
[0248] Experiments show that most of the time, when Wh=1 and Ws=0, then W hs =1. When Wh=0, Ws=1, then W hs =1. When Wh=0, Ws=0, then W hs =0. Furthermore, Wh=1 and Ws=1 are contradictory and this situation will not actually occur.
[0249] Based on the total entropy weight obtained from the two-dimensional chromaticity histogram, it can be seen that the influence of non-white pure color blocks on the subsequent calculation of white balance gain can be effectively avoided.
[0250] In this embodiment, considering that when the entropy is relatively small, the image patch may be a non-texture region with a large number of white points, or it may be a non-texture region without a large number of white points. Therefore, it is also necessary to consider non-texture white point concentrations and non-texture non-white point concentrations. Therefore, a total entropy weight Whs = Wh*Ws+(1-Ws) is introduced to ensure that the entropy weight has a more accurate impact on the white balance gain.
[0251] The process of determining color temperature weights is explained below.
[0252] In one embodiment, such as Figure 17 A flowchart illustrating the process of determining color temperature weights is shown. The first weight parameters for each image patch are determined, including:
[0253] Step 1701: For each image block, determine the exposure parameters of the image block.
[0254] Color temperature weights can characterize the probability that the light source of an image patch is of the color temperature type corresponding to that color temperature weight.
[0255] The probability of a light source for each image patch can be determined by weighting the light source based on its characteristics and necessary prior knowledge; this weighting is known as color temperature weighting. For example, in a scene, the brighter the light source, the lower the probability that it is a fluorescent lamp.
[0256] In this embodiment, the exposure parameter can be BV, where BV represents the absolute brightness of a specific scene, which can be calculated using relevant exposure data. For example, the brightness value BV of the scene can be calculated using the SV value represented by the exposure gain ISO, the light source value AV, and the shutter speed value TV.
[0257]
[0258] Step 1702: Obtain the fifth correspondence relationship, which is a pre-determined correspondence relationship between multiple sets of different exposure parameters and different color temperature weights.
[0259] For example, obtaining the fifth correspondence includes: determining the primary color temperature type of the image block; and obtaining a preset correspondence corresponding to the primary color temperature type as the fifth correspondence based on the color temperature type.
[0260] The primary color temperature type represents the color temperature of the light source that has the greatest impact on the image patch.
[0261] Determining the dominant color temperature type of an image patch includes: counting the number of second pixels corresponding to each color temperature range. The color temperature type of the color temperature region with the largest number of corresponding second pixels is taken as the primary color temperature type.
[0262] That is, based on the number of white points at each color temperature output for each image block. The color temperature corresponding to the largest CntTotal value is selected as the main color temperature type of the image block.
[0263] Different color temperature types correspond to different preset mappings, for example, Figure 18 The diagram illustrates the correspondence between multiple sets of different exposure parameters and different color temperature weights when the color temperature type is sunlight color temperature; Figure 19The diagram illustrates the correspondence between multiple sets of different exposure parameters and different color temperature weights when the color temperature type is incandescent and fluorescent lamp color temperature. Figure 20 The diagram shows the correspondence between multiple sets of different exposure parameters and different color temperature weights when the color temperature type is cloudy weather. Figure 21 This illustrates the correspondence between multiple sets of different exposure parameters and different color temperature weights when the color temperature type is set to "cloudy weather". When the primary color temperature type is determined to be "sunlight color temperature", then... Figure 18 The diagram shows the fifth correspondence. Here, BVWeight represents the color temperature weight.
[0264] Step 1703: Determine the color temperature weight of the image block based on the exposure parameters and the fifth correspondence.
[0265] In this application embodiment, the correspondence between color temperature weights and exposure parameters under different color temperatures is given. This ensures that accurate color temperature weights can be determined under each color temperature type, and that the influence of color temperature weights on white balance gain is accurate.
[0266] The process of determining the quantity weights is explained below.
[0267] In one embodiment, determining the first weight parameter of each image block includes: determining the number of second pixels in the image block; obtaining the quantity weight based on the number of second pixels and a sixth correspondence; the sixth correspondence is a pre-determined correspondence between the number of different second pixels and different quantity weights.
[0268] As mentioned above, the second pixel in each image block has been selected, and the number of second pixels in each image block at each standard color temperature has also been output: .
[0269] For example, the sixth relation function curve formed by the correspondence between multiple sets of different numbers of second pixels and different number weights is as follows: Figure 22 As shown, the horizontal axis represents the number of second pixels, and the vertical axis represents the number weight PWeight.
[0270] In one embodiment, such as Figure 23 A flowchart illustrating the process of determining white balance gain is shown. Based on the first weight parameter of each image block and the channel value data of each image block, the white balance gain is determined, including:
[0271] Step 2301: Based on the first weight parameter, perform weighted summation on the channel value data of each image block to obtain the weighted statistical values corresponding to different channels.
[0272] For example, the weighted statistics for the R channel are:
[0273]
[0274] The weighted statistical value of channel G is:
[0275]
[0276] The weighted statistical value of channel B is:
[0277]
[0278] As can be seen from the above, , , This refers to the channel value data for the x*y-th image patch. Furthermore, Let x*y be the entropy weight of the x*y-th image patch. The color temperature weight for the x*y-th image patch. The number weight of the x*y-th image patch.
[0279] In this embodiment, the weight of each image block in the final RTotal, GTotal, and BTotal statistics is determined based on the entropy information of each image block, the color temperature information of the main light source of each image block, and the number of white points in each image block. Finally, the weighted RTotal, GTotal, and BTotal are used to calculate the final total gain value. Alternatively, the histogram information in the horizontal and vertical coordinate directions of the chromaticity coordinate system can be calculated separately, and the variance or standard deviation of the block can be used to represent the texture richness of the current block.
[0280] These statistics are determined based on the light source probability and texture richness of each image patch. The white balance gain is then determined based on this, which greatly eliminates the influence of large areas of large color blocks.
[0281] Step 2302: Determine the white balance gain based on the weighted statistical values corresponding to different channels.
[0282] The white balance gain is determined based on the weighted statistical values corresponding to different channels, including:
[0283] First, determine the maximum value among the weighted statistics for each channel. .
[0284] Right now: .
[0285] Secondly, the ratio of the maximum value to the weighted statistical value corresponding to each other channel is calculated to obtain the target gain value for each channel; each target gain value is used as the white balance gain.
[0286] Right now:
[0287] , and As white balance gain.
[0288] This white balance gain can be used to adjust the white balance of the target image.
[0289] In summary, to overcome the shortcomings of existing white balance adjustment techniques, improve white balance accuracy, and adapt to white balance effects in complex scenes and large-area monochromatic scenes, this application proposes a robust and adaptable automatic white balance method. This automatic white balance method is applied as follows: Figure 24 In the image processing flow shown, the white balance correction step uses the white balance algorithm provided in this application to perform white balance processing to ensure stable image white balance.
[0290] The automatic white balance method as a whole includes:
[0291] 1. Raw data de-mosaic. Raw data is acquired through a CMOS image sensor. For each pixel, a 5*5 neighborhood linear interpolation is used to generate the two missing component data for each CFA pixel, thus reducing noise interference while preserving color temperature information.
[0292] 2. Image segmentation. Divide the entire image into multiple image blocks.
[0293] 3. Output of Weighted Statistics for White Points in Single Image Blocks. The distribution of white points in the target color coordinate system for each sub-image block is statistically analyzed. Since excessively dark pixels contain too much noise, and excessively bright pixels tend to be saturated and cannot provide effective color temperature information, excessively dark or bright pixels are not included in the white point statistics. Pixels with intermediate brightness have progressively increasing weights from dark to bright, thereby improving the accuracy of the white point R / G / B statistical results. For pixels falling within the white area in the Log Domain target coordinate system, for white point pixels within a certain brightness range, the RGB component statistics of that block are calculated by weighting their distance from the log color temperature line, and the number of white point pixels with different color temperatures in each block is recorded.
[0294] Here, the white area range of the RGB components of white pixels at each color temperature in the chromaticity coordinate system log2(B / G)-log2(R / G) can be predefined. Each pixel in a block is checked to see if it falls within a certain white area range. When it does, the weight value of each pixel is accumulated based on its distance from the fitted line, and the statistical values of the RGB components of each block are output, along with the number of white pixels corresponding to each color temperature light source in that block. When actually calculating the chromaticity coordinate coefficients of each pixel, only the values of log2(R), log2(G), and log2(B) need to be obtained, and these values can be stored in memory or external storage in the form of a table. Under this chromaticity coordinate system, the white area statistical rectangle for each color temperature can be determined using the coordinates of the top-left and bottom-right corners of the rectangle. This white area range parameter is stored in memory or external storage for hardware determination.
[0295] 4. Output of weighted statistical values of white points in different blocks. Calculate the chromaticity entropy value of each block to obtain the chromaticity weight C_Weight, which is used to determine whether the block is a color-rich block, avoiding the influence of large areas of monochromaticity. Calculate the probability weight L_Weight of each block under different brightness levels for subject recognition light sources, and the weight obtained by calculating the number of white points in each block. Determine the total weight of each block W = C_Weight * L_Weight * P_Weight. Output the weighted values of each block to the three RGB components of the entire image.
[0296] 5. Obtain white balance gain values based on statistical data. First, select sub-image blocks where the number of white points exceeds a set threshold. If the number of white points in a sub-block reaches a certain threshold, use the white points within these sub-image blocks as the final target white points. Then, calculate the white balance gain based on the accumulated R / G / B values of these white points. Finally, use the white balance gain to perform white balance correction on the target image.
[0297] Based on this, the key points of this method are as follows:
[0298] (1) De-mosaicing of Raw data. Normally, the white balance input data is the raw data after color interpolation. However, color interpolation affects the color temperature information in the image, making it difficult to accurately estimate the color temperature of the original image. In this invention, the original image is divided into n*m blocks. Before color interpolation, the average value of the R / G / B components is calculated within a 5*5 neighborhood and used as the RGB three-component value of the neighborhood center pixel. This reduces noise interference while preserving the original pixel color temperature information in the RAW domain. Subsequently, the image is divided into blocks, and the statistical information of the white point RGB three components of each block is output, further reducing noise interference.
[0299] (2) Establish the target color space. The white point at each color temperature has a certain pattern in a coordinate system with R / G and B / G as the horizontal and vertical axes. This pattern also applies to the Log Domain. Under a standard light source, data from each grayscale patch of the 24-color card is collected. According to the RGB components of each pixel calculated in step one, log2(R / G) and log2(B / G) are used as the horizontal and vertical axes, respectively. The log2(R / G) and log2(B / G) ratios of each pixel in step one are projected into the Log Domain coordinate system, and a log color temperature straight line is fitted to obtain the target color space.
[0300] (3) Determination of white points based on a single pixel as the target unit. Since the coordinate regions in the target color space are basically fixed under each standard color temperature, the white point regions falling into each color temperature are considered as white points of the corresponding color temperature. The distance of the pixels falling into the white area from the line of their log color temperature is weighted, and the number of white point pixels and the RGB Total value of the three white point pixels are output to the white balance statistics information module of the corresponding block.
[0301] (4) Calculate the chromaticity entropy value in the block as the target unit to determine whether the block is a color-rich block, avoid the influence of large areas of monochrome, and use exposure information to calculate the probability weight of each block under different brightness under the main identification light source. The total RGB three-component statistical value is obtained by weighting the above information and used to calculate the white balance gain.
[0302] The effect of these key points is as follows:
[0303] On the one hand, the calibration coordinate system of the traditional color temperature estimation method is transformed to the target coordinate system, and the color temperature curve is converted into a straight line to facilitate the calculation of distance weights. On the other hand, by calculating the weights based on the chromatic entropy of each block, the brightness weights of the main light source identified in each block, and the weights based on the number of blocks, the influence of large areas of monochromatic pixels, pixels that have white pixel spectral responses under specific light sources, and a few white pixel blocks on the overall gain calculation is eliminated. In addition, the calculation sets relevant weights separately for single pixels and blocks, which is more robust than directly calculating the cumulative R / G / B values of each target white pixel.
[0304] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0305] Based on the same inventive concept, this application also provides a white balance adjustment device for implementing the white balance adjustment method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations of the one or more white balance adjustment device embodiments provided below can be found in the limitations of the white balance adjustment method described above, and will not be repeated here.
[0306] In one embodiment, such as Figure 25 As shown, a white balance adjustment device is provided. The white balance adjustment device 2500 includes: an image segmentation module 2501, a parameter determination module 2502, a gain determination module 2503, and an image adjustment module 2504, wherein:
[0307] The image segmentation module 2501 is used to segment the target image into blocks to obtain multiple image blocks corresponding to the target image; wherein each image block includes multiple pixels in the target image.
[0308] The parameter determination module 2502 is used to determine the first weight parameter of each image block; the first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet the preset conditions.
[0309] The gain determination module 2503 is used to determine the white balance gain of the target image based on each first weight parameter.
[0310] Image adjustment module 2504 is used to perform white balance adjustment processing on the target image based on white balance gain.
[0311] In one embodiment, the gain determination module 2503 is specifically used to: for each image block, perform weighted processing on the channel values of pixels in the image block that meet the preset conditions to obtain the channel value data corresponding to the image block; and determine the white balance gain according to the first weight parameter of each image block and the channel value data of each image block.
[0312] In one embodiment, the gain determination module 2503 is specifically configured to: determine a plurality of first pixels in an image block that satisfy a preset channel value condition; determine a second pixel from the plurality of first pixels that satisfies a preset brightness condition; determine a second weight parameter for each second pixel, the second weight parameter including a brightness weight related to the brightness of the second pixel and a distance weight related to the difference between the color temperature of the second pixel and the standard color temperature; and perform weighted summation on each channel value of each second pixel according to the second weight parameter to obtain the channel value data corresponding to the image block.
[0313] In one embodiment, the gain determination module 2503 is specifically used for: determining the coordinate values of each pixel in the image block in the color space coordinate system; wherein, the horizontal axis of the color space coordinate system represents the color temperature change from low to high from small to large, and the vertical axis of the color space coordinate system represents the color rendering index of the pixel; determining the coordinate value range to which the coordinate value of each pixel belongs; determining the color temperature region range corresponding to each coordinate value range according to the region range correspondence table; wherein, the region range correspondence table includes the correspondence between multiple sets of candidate color temperature regions and candidate coordinate value ranges; and taking the pixel corresponding to each color temperature region range as the first pixel.
[0314] In one embodiment, the gain determination module 2503 is specifically configured to: for each pixel, calculate the ratio of the R channel value to the G channel value of the pixel to obtain a first ratio; and calculate the ratio of the B channel value to the G channel value of the pixel to obtain a second ratio; calculate the logarithm of the first ratio to obtain a first color coordinate value of the pixel; and calculate the logarithm of the second ratio to obtain a second color coordinate value of the pixel.
[0315] In one embodiment, the gain determination module 2503 is specifically used for: establishing a color space coordinate system; determining the positions of multiple white pixels corresponding to different standard color temperatures in the color space coordinate system; fitting the positions of each white pixel in the color space coordinate system to obtain an initial fitted color temperature line; rotating the initial fitted color temperature line by a preset angle to obtain a target fitted color temperature line; and based on the target fitted color temperature line and the positions of each white pixel in the color space coordinate system, calibrating each candidate color temperature region and determining the range of candidate coordinate values corresponding to each candidate color temperature region.
[0316] In one embodiment, the gain determination module 2503 is specifically used to: use a first pixel whose brightness information is within a preset brightness range as a second pixel.
[0317] In one embodiment, the gain determination module 2503 is specifically used to: determine a reference distance parameter for the color temperature region range corresponding to the second pixel; determine an initial distance parameter based on the reference distance parameter and the second color coordinate value of the second pixel; and obtain the distance weight of the second pixel based on the initial distance parameter and a first correspondence relationship; the first correspondence relationship is a pre-determined correspondence relationship between multiple sets of different initial distance parameters and different distance weights.
[0318] In one embodiment, the gain determination module 2503 is specifically used to: determine the brightness weight of the second pixel based on the brightness information of the second pixel and the second correspondence; the second correspondence is a pre-determined correspondence between multiple sets of different brightness information and different brightness weights.
[0319] In one embodiment, the gain determination module 2503 is specifically used to: perform weighted summation processing on the channel value data of each image block according to the first weight parameter to obtain the weighted statistical value corresponding to different channels; and determine the white balance gain according to the weighted statistical value corresponding to different channels.
[0320] In one embodiment, the gain determination module 2503 is specifically used to: determine the maximum value among the weighted statistical values corresponding to each channel; calculate the ratio of the maximum value to the weighted statistical values corresponding to each channel to obtain the target gain value corresponding to each channel; and use each target gain value as the white balance gain.
[0321] In one embodiment, the parameter determination module 2502 is specifically used to: determine the entropy weight for each image block based on the U component and V component of each pixel in the image block.
[0322] In one embodiment, the parameter determination module 2502 is specifically used to: determine a first entropy weight and a second entropy weight based on the U component and V component of each pixel; determine an entropy weight based on the first entropy weight and the second entropy weight; wherein the first entropy weight is determined based on a two-dimensional chromaticity histogram constructed based on the U component and V component of each pixel; and the second entropy weight is determined based on the number of pixels in the image block whose U component and V component are within a preset chromaticity threshold range.
[0323] In one embodiment, the parameter determination module 2502 is specifically used to: construct a two-dimensional chromaticity histogram based on the U and V components of each pixel; calculate the two-dimensional entropy information of the image block based on the two-dimensional chromaticity histogram; and determine the first entropy weight based on the two-dimensional entropy information.
[0324] In one embodiment, the parameter determination module 2502 is specifically used to: obtain the first entropy weight based on the two-dimensional entropy information and the third correspondence; the third correspondence is a pre-determined correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information.
[0325] In one embodiment, the parameter determination module 2502 is specifically used to: determine the number of pixels in the image block whose U component value is less than a preset difference threshold and whose V component value is less than a preset difference threshold based on the U component and V component of each pixel, thereby obtaining the first pixel count; and determine the second entropy weight based on the first pixel count.
[0326] In one embodiment, the parameter determination module 2502 is specifically used to: obtain the second entropy weight based on the number of first pixels and the fourth correspondence; the fourth correspondence is a pre-determined correspondence between multiple sets of different second entropy weights and different numbers of first pixels.
[0327] In one embodiment, the parameter determination module 2502 is specifically used to: calculate the difference between the first preset value and the second entropy weight to obtain the first candidate weight; calculate the product of the first entropy weight and the first candidate weight to obtain the second candidate weight; and use the sum of the second entropy weight and the second candidate weight as the entropy weight.
[0328] In one embodiment, the parameter determination module 2502 is specifically used for: determining the exposure parameters of each image block; obtaining a fifth correspondence, which is a pre-determined correspondence between multiple sets of different exposure parameters and different color temperature weights; and determining the color temperature weight of the image block according to the exposure parameters and the fifth correspondence.
[0329] In one embodiment, the parameter determination module 2502: determines the primary color temperature type of the image block; and obtains a preset correspondence relationship corresponding to the primary color temperature type as the fifth correspondence relationship based on the color temperature type.
[0330] In one embodiment, determining the dominant color temperature type of an image block includes: counting the number of second pixels corresponding to each color temperature region range; and taking the color temperature type of the color temperature region range with the largest number of corresponding second pixels as the dominant color temperature type.
[0331] In one embodiment, the parameter determination module 2502: determines the number of second pixels in the image block; obtains the quantity weight based on the number of second pixels and the sixth correspondence; the sixth correspondence is a pre-determined correspondence between the number of different second pixels and different quantity weights.
[0332] In one embodiment, the apparatus further includes a format processing module, configured to: acquire RAW format image data corresponding to the target image before performing block processing on the target image; the image data includes multiple target pixels in RAW format; and perform linear interpolation processing on the channel values of each target pixel to obtain the target image.
[0333] In one embodiment, each target pixel includes a channel value corresponding to an R channel, a G channel, or a B channel; the format processing module is specifically used for: for each target pixel, determining the channel values of other pixels within a preset neighborhood of the target pixel; calculating the average value of the channel values corresponding to the first channel of each of the other pixels to obtain a first average value, and using the first average value as the pixel value corresponding to the first channel in the target pixel; calculating the average value of the channel values corresponding to the second channel of each of the other pixels to obtain a second average value, and using the second average value as the pixel value corresponding to the second channel in the target pixel; wherein, the first channel and the second channel are channels for missing channel values of the target pixel in the R channel, G channel, and B channel.
[0334] Each module in the aforementioned white balance adjustment device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0335] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 26 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores white balance adjustment data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a white balance adjustment method.
[0336] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 27As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a white balance adjustment method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0337] Those skilled in the art will understand that Figure 27 and 26 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0338] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0339] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0340] The target image is divided into blocks to obtain multiple image blocks corresponding to the target image; each image block includes multiple pixels in the target image; a first weight parameter is determined for each image block; the first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions; the white balance gain of the target image is determined according to each first weight parameter; and the white balance is adjusted according to the white balance gain.
[0341] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each image block, weighting the channel values of pixels in the image block that meet preset conditions to obtain the channel value data corresponding to the image block; and determining the white balance gain based on the first weight parameter of each image block and the channel value data of each image block.
[0342] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining a plurality of first pixels in the image block that satisfy a preset channel value condition; determining second pixels from the plurality of first pixels that satisfy a preset brightness condition; determining a second weight parameter for each second pixel, the second weight parameter including a brightness weight related to the brightness of the second pixel and a distance weight related to the difference between the color temperature of the second pixel and the standard color temperature; and performing a weighted summation of each channel value of each second pixel according to the second weight parameter to obtain the channel value data corresponding to the image block.
[0343] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the coordinate values of each pixel in the image block in a color space coordinate system; wherein, the horizontal axis of the color space coordinate system represents the color temperature change from low to high from small to large, and the vertical axis of the color space coordinate system represents the color rendering index of the pixel; determining the coordinate value range to which the coordinate value of each pixel belongs; determining the color temperature region range corresponding to each coordinate value range according to a region range correspondence table; wherein, the region range correspondence table includes multiple sets of correspondences between candidate color temperature regions and candidate coordinate value ranges; and taking the pixel corresponding to each color temperature region range as the first pixel.
[0344] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each pixel, calculating the ratio of the R channel value to the G channel value of the pixel to obtain a first ratio; and calculating the ratio of the B channel value to the G channel value of the pixel to obtain a second ratio; calculating the logarithm of the first ratio to obtain a first color coordinate value of the pixel; and calculating the logarithm of the second ratio to obtain a second color coordinate value of the pixel.
[0345] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: establishing a color space coordinate system; determining the positions of multiple white pixels corresponding to different standard color temperatures in the color space coordinate system; fitting the positions of each white pixel in the color space coordinate system to obtain an initial fitted color temperature line; rotating the initial fitted color temperature line by a preset angle to obtain a target fitted color temperature line; and based on the target fitted color temperature line and the positions of each white pixel in the color space coordinate system, calibrating each candidate color temperature region and determining the range of candidate coordinate values corresponding to each candidate color temperature region.
[0346] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: using a first pixel whose brightness information is within a preset brightness range as a second pixel.
[0347] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining a reference distance parameter for the color temperature region range corresponding to the second pixel; determining an initial distance parameter based on the reference distance parameter and the second color coordinate value of the second pixel; obtaining the distance weight of the second pixel based on the initial distance parameter and a first correspondence; the first correspondence is a pre-determined correspondence between multiple sets of different initial distance parameters and different distance weights.
[0348] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: determining the brightness weight of the second pixel based on the brightness information of the second pixel and the second correspondence; the second correspondence is a pre-determined correspondence between multiple sets of different brightness information and different brightness weights.
[0349] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: performing weighted summation on the channel value data of each image block according to the first weight parameter to obtain the weighted statistical values corresponding to different channels; and determining the white balance gain according to the weighted statistical values corresponding to different channels.
[0350] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the maximum value among the weighted statistics corresponding to each channel; calculating the ratio of the maximum value to the weighted statistics corresponding to each channel to obtain the target gain value corresponding to each channel; and using each target gain value as the white balance gain.
[0351] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each image block, determining the entropy weight based on the U and V components of each pixel in the image block.
[0352] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining a first entropy weight and a second entropy weight based on the U component and V component of each pixel; determining an entropy weight based on the first entropy weight and the second entropy weight; wherein the first entropy weight is determined based on a two-dimensional chromaticity histogram constructed based on the U component and V component of each pixel; and the second entropy weight is determined based on the number of pixels in the image block whose U component and V component are within a preset chromaticity threshold range.
[0353] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: constructing a two-dimensional chromaticity histogram based on the U and V components of each pixel; calculating the two-dimensional entropy information of the image block based on the two-dimensional chromaticity histogram; and determining the first entropy weight based on the two-dimensional entropy information.
[0354] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the first entropy weight based on the two-dimensional entropy information and the third correspondence; the third correspondence is a pre-determined correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information.
[0355] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the number of pixels in the image block whose U component value is less than a preset difference threshold and whose V component value is less than a preset difference threshold, based on the U component and V component of each pixel, to obtain a first pixel count; and determining a second entropy weight based on the first pixel count.
[0356] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining a second entropy weight based on the number of first pixels and a fourth correspondence; the fourth correspondence is a predetermined correspondence between multiple sets of different second entropy weights and different numbers of first pixels.
[0357] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: calculating the difference between the first preset value and the second entropy weight to obtain the first candidate weight; calculating the product of the first entropy weight and the first candidate weight to obtain the second candidate weight; and using the sum of the second entropy weight and the second candidate weight as the entropy weight.
[0358] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each image block, determining the exposure parameters of the image block; obtaining a fifth correspondence, which is a pre-determined correspondence between multiple sets of different exposure parameters and different color temperature weights; and determining the color temperature weight of the image block according to the exposure parameters and the fifth correspondence.
[0359] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the primary color temperature type of the image block; and obtaining a preset correspondence relationship corresponding to the primary color temperature type as a fifth correspondence relationship based on the color temperature type.
[0360] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: counting the number of second pixels corresponding to each color temperature range; and taking the color temperature type of the color temperature range with the largest number of corresponding second pixels as the primary color temperature type.
[0361] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the number of second pixels in the image block; obtaining the quantity weight based on the number of second pixels and a sixth correspondence; the sixth correspondence is a pre-determined correspondence between the number of different second pixels and different quantity weights.
[0362] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: acquiring RAW format image data corresponding to the target image; the image data includes multiple target pixels in RAW format; and performing linear interpolation on the channel values of each target pixel to obtain the target image.
[0363] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each target pixel, determining the channel values of other pixels within a preset neighborhood of the target pixel; calculating the average value of the channel values corresponding to the first channel of each other pixel to obtain a first average value, and using the first average value as the pixel value corresponding to the first channel in the target pixel; calculating the average value of the channel values corresponding to the second channel of each other pixel to obtain a second average value, and using the second average value as the pixel value corresponding to the second channel in the target pixel; wherein the first channel and the second channel are channels for missing channel values of the target pixel in the R channel, G channel and B channel.
[0364] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0365] The target image is divided into blocks to obtain multiple image blocks corresponding to the target image; each image block includes multiple pixels in the target image; a first weight parameter is determined for each image block; the first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions; the white balance gain of the target image is determined according to each first weight parameter; and the white balance is adjusted according to the white balance gain.
[0366] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each image block, weighting the channel values of pixels in the image block that meet preset conditions to obtain the channel value data corresponding to the image block; and determining the white balance gain based on the first weight parameter of each image block and the channel value data of each image block.
[0367] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining a plurality of first pixels in the image block that satisfy a preset channel value condition; determining second pixels from the plurality of first pixels that satisfy a preset brightness condition; determining a second weight parameter for each second pixel, the second weight parameter including a brightness weight related to the brightness of the second pixel and a distance weight related to the difference between the color temperature of the second pixel and the standard color temperature; and performing a weighted summation of each channel value of each second pixel according to the second weight parameter to obtain the channel value data corresponding to the image block.
[0368] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the coordinate values of each pixel in the image block in a color space coordinate system; wherein, the horizontal axis of the color space coordinate system represents the color temperature change from low to high from small to large, and the vertical axis of the color space coordinate system represents the color rendering index of the pixel; determining the coordinate value range to which the coordinate value of each pixel belongs; determining the color temperature region range corresponding to each coordinate value range according to a region range correspondence table; wherein, the region range correspondence table includes multiple sets of correspondences between candidate color temperature regions and candidate coordinate value ranges; and taking the pixel corresponding to each color temperature region range as the first pixel.
[0369] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each pixel, calculating the ratio of the R channel value to the G channel value of the pixel to obtain a first ratio; and calculating the ratio of the B channel value to the G channel value of the pixel to obtain a second ratio; calculating the logarithm of the first ratio to obtain a first color coordinate value of the pixel; and calculating the logarithm of the second ratio to obtain a second color coordinate value of the pixel.
[0370] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: establishing a color space coordinate system; determining the positions of multiple white pixels corresponding to different standard color temperatures in the color space coordinate system; fitting the positions of each white pixel in the color space coordinate system to obtain an initial fitted color temperature line; rotating the initial fitted color temperature line by a preset angle to obtain a target fitted color temperature line; and based on the target fitted color temperature line and the positions of each white pixel in the color space coordinate system, calibrating each candidate color temperature region and determining the range of candidate coordinate values corresponding to each candidate color temperature region.
[0371] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: using a first pixel whose brightness information is within a preset brightness range as a second pixel.
[0372] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining a reference distance parameter for the color temperature region range corresponding to the second pixel; determining an initial distance parameter based on the reference distance parameter and the second color coordinate value of the second pixel; obtaining the distance weight of the second pixel based on the initial distance parameter and a first correspondence; the first correspondence is a pre-determined correspondence between multiple sets of different initial distance parameters and different distance weights.
[0373] In one embodiment, when the computer program is executed by the processor, it further implements the following steps: determining the brightness weight of the second pixel based on the brightness information of the second pixel and the second correspondence; the second correspondence is a pre-determined correspondence between multiple sets of different brightness information and different brightness weights.
[0374] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: performing weighted summation on the channel value data of each image block according to the first weight parameter to obtain the weighted statistical values corresponding to different channels; and determining the white balance gain according to the weighted statistical values corresponding to different channels.
[0375] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the maximum value among the weighted statistics corresponding to each channel; calculating the ratio of the maximum value to the weighted statistics corresponding to each channel to obtain the target gain value corresponding to each channel; and using each target gain value as the white balance gain.
[0376] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each image block, determining the entropy weight based on the U and V components of each pixel in the image block.
[0377] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining a first entropy weight and a second entropy weight based on the U component and V component of each pixel; determining an entropy weight based on the first entropy weight and the second entropy weight; wherein the first entropy weight is determined based on a two-dimensional chromaticity histogram constructed based on the U component and V component of each pixel; and the second entropy weight is determined based on the number of pixels in the image block whose U component and V component are within a preset chromaticity threshold range.
[0378] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: constructing a two-dimensional chromaticity histogram based on the U and V components of each pixel; calculating the two-dimensional entropy information of the image block based on the two-dimensional chromaticity histogram; and determining the first entropy weight based on the two-dimensional entropy information.
[0379] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the first entropy weight based on the two-dimensional entropy information and the third correspondence; the third correspondence is a pre-determined correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information.
[0380] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the number of pixels in the image block whose U component value is less than a preset difference threshold and whose V component value is less than a preset difference threshold, based on the U component and V component of each pixel, to obtain a first pixel count; and determining a second entropy weight based on the first pixel count.
[0381] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining a second entropy weight based on the number of first pixels and a fourth correspondence; the fourth correspondence is a predetermined correspondence between multiple sets of different second entropy weights and different numbers of first pixels.
[0382] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: calculating the difference between the first preset value and the second entropy weight to obtain the first candidate weight; calculating the product of the first entropy weight and the first candidate weight to obtain the second candidate weight; and using the sum of the second entropy weight and the second candidate weight as the entropy weight.
[0383] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each image block, determining the exposure parameters of the image block; obtaining a fifth correspondence, which is a pre-determined correspondence between multiple sets of different exposure parameters and different color temperature weights; and determining the color temperature weight of the image block according to the exposure parameters and the fifth correspondence.
[0384] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the primary color temperature type of the image block; and obtaining a preset correspondence relationship corresponding to the primary color temperature type as a fifth correspondence relationship based on the color temperature type.
[0385] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: counting the number of second pixels corresponding to each color temperature range; and taking the color temperature type of the color temperature range with the largest number of corresponding second pixels as the primary color temperature type.
[0386] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: determining the number of second pixels in the image block; obtaining the quantity weight based on the number of second pixels and a sixth correspondence; the sixth correspondence is a pre-determined correspondence between the number of different second pixels and different quantity weights.
[0387] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: acquiring RAW format image data corresponding to the target image; the image data includes multiple target pixels in RAW format; and performing linear interpolation on the channel values of each target pixel to obtain the target image.
[0388] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: for each target pixel, determining the channel values of other pixels within a preset neighborhood of the target pixel; calculating the average value of the channel values corresponding to the first channel of each other pixel to obtain a first average value, and using the first average value as the pixel value corresponding to the first channel in the target pixel; calculating the average value of the channel values corresponding to the second channel of each other pixel to obtain a second average value, and using the second average value as the pixel value corresponding to the second channel in the target pixel; wherein the first channel and the second channel are channels for missing channel values of the target pixel in the R channel, G channel and B channel.
[0389] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0390] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0391] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A white balance adjustment method, characterized in that, The method includes: The target image is divided into blocks to obtain multiple image blocks corresponding to the target image; wherein each image block includes multiple pixels in the target image; A first weight parameter is determined for each of the image blocks; the first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions; The white balance gain of the target image is determined based on each of the first weight parameters; The target image is subjected to white balance adjustment processing based on the white balance gain.
2. The method according to claim 1, characterized in that, Determining the white balance gain of the target image based on each of the first weight parameters includes: For each image block, the channel values of the pixels in the image block that meet the preset conditions are weighted to obtain the channel value data corresponding to the image block; The white balance gain is determined based on the first weight parameter of each image block and the channel value data of each image block.
3. The method according to claim 2, characterized in that, For each image block, the channel values of pixels meeting preset conditions in the image block are weighted to obtain the channel value data corresponding to the image block, including: Identify multiple first pixels in the image block that satisfy a preset channel value condition; Determine a second pixel that meets a preset brightness condition from a plurality of first pixels; Determine a second weight parameter for each second pixel, the second weight parameter including a brightness weight related to the brightness of the second pixel and a distance weight related to the difference between the color temperature of the second pixel and the standard color temperature; Based on the second weight parameter, the channel values of each second pixel are weighted and summed to obtain the channel value data corresponding to the image block.
4. The method according to claim 3, characterized in that, The step of determining multiple first pixels in the image block that satisfy the preset channel value condition includes: Determine the coordinate values of each pixel in the image block in the color space coordinate system; wherein, the horizontal axis of the color space coordinate system represents the first color coordinate value; the first color coordinate value is related to the color temperature and the color temperature changes from low to high as it increases from small to large; the vertical axis of the color space coordinate system represents the second color coordinate value, and the second color coordinate value is related to the color rendering index; Determine the range of coordinate values to which the coordinate values of each pixel belong; Based on the region range correspondence table, determine the color temperature region range corresponding to each coordinate value range; wherein, the region range correspondence table includes the correspondence between multiple sets of candidate color temperature regions and candidate coordinate value ranges; The pixel corresponding to each color temperature range is taken as the first pixel.
5. The method according to claim 4, characterized in that, Determining the coordinates of each pixel in the image block in the color space coordinate system includes: For each pixel, the ratio of the R channel value to the G channel value of the pixel is calculated to obtain a first ratio; and the ratio of the B channel value to the G channel value of the pixel is calculated to obtain a second ratio. Calculate the logarithm of the first ratio to base 2 to obtain the first color coordinate value of the pixel; and calculate the logarithm of the second ratio to base 2 to obtain the second color coordinate value of the pixel.
6. The method according to claim 4, characterized in that, The process of determining the corresponding table for the region range includes: Establish the color space coordinate system; Determine the positions of multiple pre-calibrated white pixels corresponding to different standard color temperatures in the color space coordinate system; By fitting the position of each white pixel in the color space coordinate system, an initial fitted color temperature line is obtained; The initial fitted color temperature line is rotated by a preset angle to obtain the target fitted color temperature line; Based on the target fitted color temperature line and the position of each white pixel in the color space coordinate system, each candidate color temperature region is calibrated, and the range of candidate coordinate values corresponding to each candidate color temperature region is determined.
7. The method according to claim 3, characterized in that, Determining a second pixel that satisfies a preset brightness condition from a plurality of first pixel points includes: The first pixel whose brightness information falls within the preset brightness range is used as the second pixel.
8. The method according to claim 3, characterized in that, The determination of the second weight parameter for each second pixel includes: Determine the reference distance parameter for the color temperature region range corresponding to the second pixel; The initial distance parameter is determined based on the reference distance parameter and the second color coordinate value of the second pixel. The distance weight of the second pixel is obtained based on the initial distance parameters and the first correspondence; the first correspondence is a pre-determined correspondence between multiple sets of different initial distance parameters and different distance weights.
9. The method according to claim 3, characterized in that, The determination of the second weight parameter for each second pixel includes: The brightness weight of the second pixel is determined based on the brightness information of the second pixel and the second correspondence; the second correspondence is a pre-determined correspondence between multiple sets of different brightness information and different brightness weights.
10. The method according to claim 2, characterized in that, The step of determining the white balance gain based on the first weight parameter of each image block and the channel value data of each image block includes: Based on the first weight parameter, the channel value data of each image block are weighted and summed to obtain the weighted statistical values corresponding to different channels; The white balance gain is determined based on the weighted statistical values corresponding to the different channels.
11. The method according to claim 10, characterized in that, The step of determining the white balance gain based on the weighted statistical values corresponding to the different channels includes: Determine the maximum value among the weighted statistical values corresponding to each channel; Calculate the ratio of the maximum value to the weighted statistical value corresponding to other channels to obtain the target gain value for each channel; Each of the target gain values is used as the white balance gain.
12. The method according to claim 1, characterized in that, Determining the first weight parameter for each of the image blocks includes: For each image block, the entropy weight is determined based on the U and V components of each pixel in the image block.
13. The method according to claim 12, characterized in that, Determining the entropy weight based on the U and V components of each pixel in the image block includes: The first entropy weight and the second entropy weight are determined based on the U component and V component of each pixel. The entropy weight is determined based on the first entropy weight and the second entropy weight; The first entropy weight is determined based on a two-dimensional chromaticity histogram constructed from the U and V components of each pixel; the second entropy weight is determined based on the number of pixels in the image block whose U and V components are within a preset chromaticity threshold range.
14. The method according to claim 13, characterized in that, The process of determining the first entropy weight based on the U and V components of each pixel includes: A two-dimensional chromaticity histogram is constructed based on the U and V components of each pixel. Based on the two-dimensional chromaticity histogram, the two-dimensional entropy information of the image patch is calculated; The first entropy weight is determined based on the two-dimensional entropy information.
15. The method according to claim 14, characterized in that, Determining the first entropy weight based on the two-dimensional entropy information includes: The first entropy weight is obtained based on the two-dimensional entropy information and the third correspondence; the third correspondence is a pre-determined correspondence between multiple sets of different first entropy weights and different two-dimensional entropy information.
16. The method according to claim 13, characterized in that, The process of determining the second entropy weight based on the U and V components of each pixel includes: Based on the U and V components of each pixel, determine the number of pixels in the image block whose U component value is less than a preset difference threshold and whose V component value is less than a preset difference threshold, and obtain the first pixel count. The second entropy weight is determined based on the number of the first pixels.
17. The method according to claim 16, characterized in that, Determining the second entropy weight based on the number of the first pixels includes: The second entropy weight is obtained based on the first number of pixels and the fourth correspondence; the fourth correspondence is a pre-determined correspondence between multiple sets of different second entropy weights and different numbers of first pixels.
18. The method according to claim 13, characterized in that, Determining the entropy weight based on the first entropy weight and the second entropy weight includes: The difference between the first preset value and the second entropy weight is calculated to obtain the first candidate weight; Calculate the product of the first entropy weight and the first candidate weight to obtain the second candidate weight; The sum of the second entropy weight and the second candidate weight is used as the entropy weight.
19. The method according to claim 4, characterized in that, Determining the first weight parameter for each of the image blocks includes: For each of the image blocks, determine the exposure parameters for that image block; Obtain the fifth correspondence, which is a pre-determined correspondence between multiple sets of different exposure parameters and different color temperature weights; The color temperature weight of the image block is determined based on the exposure parameters and the fifth correspondence.
20. The method according to claim 19, characterized in that, The process of obtaining the fifth correspondence includes: Determine the dominant color temperature type of the image block; Based on the color temperature type, a preset correspondence relationship corresponding to the main color temperature type is obtained as the fifth correspondence relationship.
21. The method according to claim 20, characterized in that, Determining the dominant color temperature type of the image block includes: The number of the second pixel points corresponding to each of the aforementioned color temperature ranges is counted respectively; The color temperature type of the color temperature region with the largest number of corresponding second pixels is taken as the primary color temperature type.
22. The method according to claim 3, characterized in that, Determining the first weight parameter for each of the image blocks includes: Determine the number of the second pixel points in the image block; The quantity weight is obtained based on the number of the second pixel and the sixth correspondence; the sixth correspondence is a pre-determined correspondence between the number of different second pixels and different quantity weights.
23. The method according to claim 1, characterized in that, Before performing block segmentation on the target image, the method further includes: Acquire the RAW format image data corresponding to the target image; the image data includes multiple target pixels in RAW format. The target image is obtained by performing linear interpolation on the channel values of each target pixel.
24. The method according to claim 23, characterized in that, Each target pixel includes a channel value corresponding to an R channel, G channel, or B channel; the linear interpolation processing of the channel values of each target pixel includes: For each target pixel, determine the channel values of other pixels within a preset neighborhood of the target pixel; Calculate the average value of the channel value corresponding to the first channel of each of the other pixels to obtain the first average value, and use the first average value as the pixel value corresponding to the first channel in the target pixel; Calculate the average value of the channel values corresponding to the second channel of each of the other pixels to obtain the second average value, and use the second average value as the pixel value corresponding to the second channel of the target pixel; wherein, the first channel and the second channel are the channels of the target pixel that have missing channel values among the R channel, G channel and B channel.
25. A white balance adjustment device, characterized in that, The device includes: An image segmentation module is used to segment a target image into blocks to obtain multiple image blocks corresponding to the target image; wherein each image block includes multiple pixels in the target image; A parameter determination module is used to determine a first weight parameter for each of the image blocks; the first weight parameter includes an entropy weight related to the chromaticity of the image block, a color temperature weight related to the light source color temperature of the image block, and a quantity weight related to the number of pixels in the image block that meet preset conditions; A gain determination module is used to determine the white balance gain of the target image based on each of the first weight parameters; An image adjustment module is used to perform white balance adjustment processing on the target image according to the white balance gain.
26. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 24.
27. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 24.
28. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 24.