An adaptive white balance method and device, electronic equipment and storage medium
By adaptively selecting a white balance algorithm and combining it with downsampling technology, the efficiency and effectiveness of white balance correction for 8K ultra-high-definition camera images in complex scenes have been solved, achieving efficient and accurate correction in different scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SICHUAN NATIONAL INNOVATION VISION UHD VIDEO TECHNOLOGY CO LTD
- Filing Date
- 2023-05-19
- Publication Date
- 2026-07-21
AI Technical Summary
Existing automatic white balance algorithms are complex and unable to adapt to color deviations in different scenes when processing images captured by 8K ultra-high-definition cameras. They are prone to failure or correction errors, especially in complex scenes.
By acquiring the pixel distribution histogram of each channel of the image, calculating the brightness and channel ratio, and adaptively selecting truncation processing, QCGP algorithm, mapping processing or histogram equalization translation algorithm for white balance correction, and performing downsampling before statistical histogram to reduce computational complexity.
It achieves efficient and accurate white balance correction in complex scenes with varying brightness and color cast, and is applicable to 8K images and other formats, improving computational efficiency and correction effect.
Smart Images

Figure CN116489330B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and in particular relates to an adaptive white balance method, apparatus, electronic device and storage medium. Background Technology
[0002] Automatic white balance algorithms aim to analyze image signals and simulate the constancy of human color perception, thereby overcoming the influence of light source color on imaging and restoring the true color information of the image itself. It is a crucial step in the digital image signal processing workflow. Current automatic white balance algorithms can be divided into two categories: hypothesis-based algorithms and histogram-based algorithms.
[0003] Hypothesis-based algorithms make assumptions about the overall color or the brightest pixels of an image based on its color information. These mainly include the gray-world method, perfect reflection method, QCGP method, and dynamic thresholding method. The gray-world method is relatively simple, but it assumes that the average pixel value of the RGB channels is gray for richly colored images, and it fails for images with many monochrome blocks. The perfect reflection method and dynamic thresholding method make assumptions about white points in the original image through analysis and calculation, but when the brightest point in the original image is not a white point or there are no white points in the original image, color correction will show significant deviations. The QCGP method (Quadratic Combining Grey-World Perfect-Reflection Resumption) integrates and improves upon the gray-world and perfect reflection assumptions by defining a color equation and solving for the compensation coefficients of each channel. Although this method effectively improves white balance, it still cannot accurately reproduce colors for images that are generally dark and contain many monochrome blocks.
[0004] Histogram-based algorithms primarily employ histogram translation and matching, maximizing the overlap area of different channels. This method is effectively applicable to images with severe color casts (where the overlap area of the three channel histograms is extremely small, and the overall tone is noticeably biased towards one of the R, G, and B colors). However, for footage captured by 8K ultra-high-definition cameras, this method still faces two challenges: firstly, the algorithm's complexity—8K images have an extremely large pixel count, and calculating the global histogram incurs a significant time burden; secondly, the randomness of the scene—for images with slight color casts or low brightness, adjusting the center position or shape of different channel histograms can lead to a loss of color details. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide an adaptive white balance method, device, electronic device and storage medium.
[0006] The objective of this invention is achieved through the following technical solution: According to a first aspect of the present invention, an adaptive white balance method includes: Acquire the image to be processed, wherein the image to be processed is in RGB format; Statistically analyze the pixel distribution histogram of each channel of the image to be processed; The proportion of pixels in the image to be processed whose brightness values are below a preset brightness threshold is calculated and denoted as the first proportion. Calculate the proportion of overlapping pixels in the R, G, and B channels of the image to be processed, and denot it as the second proportion; The white balance algorithm is determined based on the first ratio and the second ratio, and the white balance algorithm is used to correct the white balance of the image to be processed.
[0007] Furthermore, the adaptive white balance method also includes: Before calculating the pixel distribution histogram of each channel of the image to be processed, the image to be processed is downsampled.
[0008] Further, a white balance algorithm is determined based on the first ratio and the second ratio, and the white balance algorithm is used to perform white balance correction on the image to be processed, including: If the first ratio is greater than the first threshold and the second ratio is greater than the second threshold, then the image to be processed is white balance corrected by the truncation method, and the truncation threshold of the truncation process is the first threshold. If the first ratio is greater than the first threshold and the second ratio is less than or equal to the second threshold, then the QCGP algorithm is used to perform white balance correction on the image to be processed. If the first ratio is less than or equal to the first threshold and the second ratio is greater than the second threshold, then the white balance of the image to be processed is corrected by a mapping process, and the mapping threshold of the mapping process is the first threshold. If the first ratio is less than or equal to the first threshold and the second ratio is less than or equal to the second threshold, then the histogram equalization translation algorithm is used to perform white balance correction on the image to be processed.
[0009] Furthermore, a truncation method is used to perform white balance correction on the image to be processed. The truncation threshold for the truncation process is the first threshold, including: The image to be processed is Space conversion to Space, computation Calculate the mean and variance of the variance. The mean and variance, where, Indicates blue component information. Indicates the red component information; Pixels in the image to be processed that conform to a preset rule are identified as initial white reference points. The preset rule is as follows: In the formula, for The mean, for The mean, for variance for The variance; Use the points with the first 5% to 15% of the brightness values in the initial white reference as the final white reference points; Calculate the average value of the R, G, and B channels of the final white reference point; Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is as follows: In the formula, This is the compensation coefficient for the R channel. This is the compensation coefficient for the G channel. This is the compensation coefficient for channel B. This represents the average value of the R channel. This is the average value of channel B. This is the average value of the G channel. This indicates that the image to be processed will be converted to... The maximum value of the Y channel after the channel; Based on the diagonal relationship, the pixel values of each pixel in the image to be processed are adjusted using a compensation coefficient: In the formula, Clip(•) represents the cutoff function, i.e. , This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
[0010] Furthermore, the QCGP algorithm is used to perform white balance correction on the image to be processed, including: Calculate the maximum pixel value and the first transformation coefficient of the image to be processed. The formula for calculating the first transformation coefficient is as follows: In the formula, The first transformation coefficient, The maximum pixel value in the R channel of the image to be processed. The maximum pixel value in the B channel of the image to be processed. The maximum pixel value of the image to be processed in the G channel; Calculate the average pixel value of the image to be processed and the second transform coefficient. The formula for calculating the second transform coefficient is as follows: In the formula, These are the second transformation coefficients. The average pixel value of the image to be processed in the R channel. The average pixel value of the image to be processed in the B channel. The average pixel value of the image to be processed in the G channel; Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is as follows: In the formula, Represents the second-order compensation coefficient of the R channel. Represents the first-order compensation coefficient of the R channel. This represents the second-order compensation coefficient of the G channel. This represents the first-order compensation coefficient of the G channel. This represents the second-order compensation coefficient for channel B. This represents the first-order compensation coefficient for channel B; Adjust the pixel values of each pixel in the image to be processed according to the compensation coefficient: In the formula, This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
[0011] Furthermore, a white balance correction is performed on the image to be processed using a mapping processing method. The mapping threshold for the mapping processing is the first threshold, including: The image to be processed is Space conversion to Space, computation Calculate the mean and variance of the variance. The mean and variance, where, Indicates blue component information. Indicates the red component information; Pixels in the image to be processed that conform to a preset rule are identified as initial white reference points. The preset rule is as follows: In the formula, for The mean, for The mean, for variance for The variance; Use the points with the first 5% to 15% of the brightness values in the initial white reference as the final white reference points; Calculate the average value of the R, G, and B channels of the final white reference point; Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is as follows: In the formula, This is the compensation coefficient for the R channel. This is the compensation coefficient for the G channel. This is the compensation coefficient for channel B. This represents the average value of the R channel. This is the average value of channel B. This is the average value of the G channel. This indicates that the image to be processed will be converted to... The maximum value of the Y channel after the channel; Based on the diagonal relationship, the pixel values of each pixel in the image to be processed are adjusted using a compensation coefficient: Where Scale(•) represents the normalization function, i.e. , This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel in the image to be processed, where X represents the pixel value after normalization. This represents the minimum value of a pixel after normalization. This represents the maximum value of a pixel after normalization.
[0012] Furthermore, a histogram equalization translation algorithm is used to perform white balance correction on the image to be processed, including: Calculate the images to be processed separately , , The peak positions of the histograms for the three channels are sorted in ascending order; Correcting color channels that are too small or too large based on peak difference: In the formula, Image to be processed The peak position of the channel's histogram. Image to be processed The peak position of the channel's histogram. Image to be processed The peak position of the channel's histogram. This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
[0013] According to a second aspect of the present invention, an adaptive white balance device comprises: An image acquisition module is used to acquire an image to be processed, wherein the image to be processed is in RGB format; The histogram statistics module is used to calculate the pixel distribution histogram of each channel of the image to be processed; The first calculation module is used to calculate the proportion of pixels in the image to be processed whose brightness values are below a preset brightness threshold, denoted as the first proportion. The second calculation module is used to calculate the proportion of overlapping pixels in the R, G, and B channels of the image to be processed, which is denoted as the second proportion. The white balance correction module is used to determine the white balance algorithm based on the first ratio and the second ratio, and to perform white balance correction on the image to be processed using the white balance algorithm.
[0014] According to a third aspect of the present invention, an electronic device includes: Memory, the memory storing execution instructions; and A processor that executes execution instructions stored in the memory, causing the processor to perform the adaptive white balance method according to the first aspect of the present invention.
[0015] According to a fourth aspect of the present invention, a computer-readable storage medium stores executable instructions that, when executed by a processor, are used to implement the adaptive white balance method described in the first aspect of the present invention.
[0016] The beneficial effects of this invention are: (1) Existing white balance algorithms are only applicable to certain specific scenarios (such as scenes with rich colors, or scenes where the brightest point is a white dot), or they are prone to losing color detail information (such as histogram-based algorithms). They are not universally applicable to complex scenes, and in practical applications of complex scenes, they may fail on a large scale or cause white balance correction errors. This invention introduces the frequency information of each color channel as a priori judgment, divides the original image into four categories according to the color distribution characteristics, sets a threshold mechanism, and adaptively selects an algorithm to achieve white balance correction; (2) Obtaining histograms requires statistical analysis of global image information, which is too complex for data acquired by 8K ultra-high-definition cameras. Since different sampling scales have a negligible impact on color distribution, this invention designs downsampling preprocessing to reduce image pixel values and thus improve the efficiency of histogram statistics and calculation, ensuring that the application of histogram information does not impose an excessive time burden on the overall process. Attached Figure Description
[0017] Figure 1This is a flowchart of one embodiment of the adaptive white balance method in this invention; Figure 2 For testing image one; Figure 3 Image 2 is for testing; Figure 4 Image 3 is for testing; Figure 5 For testing image four; Figure 6 This is a test image after white balance processing using the method of this invention; Figure 7 The second test image is shown after white balance processing using the method of this invention. Figure 8 The third test image is shown after white balance processing using the method of this invention. Figure 9 The fourth test image is a white balance image processed using the method of this invention. Figure 10 This is a block diagram illustrating one embodiment of the adaptive white balance method in this invention. Detailed Implementation
[0018] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] See Figures 1 to 10 This invention provides an adaptive white balance method, apparatus, electronic device, and storage medium: The first aspect of this embodiment discloses an adaptive white balance method. For example... Figure 1 As shown, the adaptive white balance method includes steps S100 to S500. These are described in detail below.
[0020] Step S100. Obtain the image to be processed, wherein the image to be processed is in RGB format.
[0021] For example, the dimensions of the image to be processed are 7680 (W) × 4320 (H) × 3 (Channels).
[0022] Step S200. Calculate the pixel distribution histogram of each channel of the image to be processed.
[0023] Step S300. Calculate the proportion of pixels in the image to be processed whose brightness values are below a preset brightness threshold, and denot it as the first proportion.
[0024] The brightness value in step S300 refers to the total pixel sum of the three channels R, G, and B of the image, which represents the overall brightness of the image. Generally, the larger the sum, the higher the brightness.
[0025] Step S400. Calculate the proportion of overlapping pixels in the R, G, and B channels of the image to be processed, and denot it as the second proportion.
[0026] It should be noted that the execution order of steps S300 and S400 is not restricted. That is, steps S300 and S400 can be executed simultaneously, or steps S300 can be executed first and then steps S400, or steps S400 can be executed first and then steps S300.
[0027] Step S500. Determine the white balance algorithm according to the first ratio and the second ratio, and use the white balance algorithm to perform white balance correction on the image to be processed.
[0028] In some embodiments, determining a white balance algorithm based on the first ratio and the second ratio, and using the white balance algorithm to perform white balance correction on the image to be processed, includes: Step S510. If the first ratio is greater than the first threshold and the second ratio is greater than the second threshold, then the image to be processed is white-balanced by a truncation method, wherein the truncation threshold of the truncation process is the first threshold.
[0029] The first threshold and the second threshold can be selected through testing on a large dataset. For example, the first threshold can be 0.7 and the second threshold can be 0.15.
[0030] When the first ratio is greater than the first threshold and the second ratio is greater than the second threshold, the overall image is too dark and the color cast is not obvious. The specific correction steps are as follows: Step A1. Transfer the image to be processed from... Space conversion to Space, computation Calculate the mean and variance of the variance. The mean and variance, where, Indicates blue component information. This indicates the red component information.
[0031] Step A2. Determine the pixels in the image to be processed that conform to a preset rule as the initial white reference points. The preset rule is as follows: In the formula, for The mean, for The mean, for variance for The variance.
[0032] Step A3. Select the points with the first 5% to 15% of the brightness values in the initial white reference as the final white reference points.
[0033] In some embodiments, the top 10% of the brightness values in the initial white reference can be used as the final white reference point.
[0034] Step A4. Calculate the average value of the R, G, and B channel pixels of the final white reference point.
[0035] Step A5. Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is: In the formula, This is the compensation coefficient for the R channel. This is the compensation coefficient for the G channel. This is the compensation coefficient for channel B. This represents the average value of the R channel. This is the average value of channel B. This is the average value of the G channel. This indicates that the image to be processed will be converted to... The maximum value of the Y channel after the channel.
[0036] Step A6. Adjust the pixel values of each pixel in the image to be processed using compensation coefficients based on the diagonal relationship: In the formula, Clip(•) represents the cutoff function, i.e. , This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
[0037] Step S520. If the first ratio is greater than the first threshold and the second ratio is less than or equal to the second threshold, then the QCGP algorithm is used to perform white balance correction on the image to be processed.
[0038] When the first ratio is greater than the first threshold and the second ratio is less than or equal to the second threshold, the overall image is too dark and has a severe color cast. The specific correction steps are as follows: Step B1. Calculate the maximum pixel value and the first transformation coefficient of the image to be processed. The formula for calculating the first transformation coefficient is as follows: In the formula, The first transformation coefficient, The maximum pixel value in the R channel of the image to be processed. The maximum pixel value in the B channel of the image to be processed. This represents the maximum pixel value in the G channel of the image to be processed.
[0039] Step B2. Calculate the average pixel value and the second transform coefficient of the image to be processed. The formula for calculating the second transform coefficient is as follows: In the formula, These are the second transformation coefficients. The average pixel value of the image to be processed in the R channel. The average pixel value of the image to be processed in the B channel. This represents the average pixel value of the image to be processed in the G channel.
[0040] Step B3. Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is: In the formula, Represents the second-order compensation coefficient of the R channel. Represents the first-order compensation coefficient of the R channel. This represents the second-order compensation coefficient of the G channel. This represents the first-order compensation coefficient of the G channel. This represents the second-order compensation coefficient for channel B. This represents the first-order compensation coefficient for channel B.
[0041] Step B4. Adjust the pixel values of each pixel in the image to be processed according to the compensation coefficient: In the formula, This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
[0042] Step S530. If the first ratio is less than or equal to the first threshold and the second ratio is greater than the second threshold, then the white balance of the image to be processed is corrected by a mapping processing method, wherein the mapping threshold of the mapping processing is the first threshold.
[0043] When the first ratio is less than or equal to the first threshold and the second ratio is greater than the second threshold, the overall image is too bright and the color cast is not obvious. The specific correction steps are as follows: Step C1. Transfer the image to be processed from... Space conversion to Space, computation Calculate the mean and variance of the variance. The mean and variance, where, Indicates blue component information. This indicates the red component information.
[0044] Pixels in the image to be processed that conform to a preset rule are identified as initial white reference points. The preset rule is as follows: In the formula, for The mean, for The mean, for variance for The variance.
[0045] Step C2. Select the points with the first 5% to 15% of the brightness values in the initial white reference as the final white reference points.
[0046] In some embodiments, the top 10% of the brightness values in the initial white reference can be used as the final white reference point.
[0047] Step C3. Calculate the average value of the R, G, and B channel pixels of the final white reference point.
[0048] Step C4. Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is: In the formula, This is the compensation coefficient for the R channel. This is the compensation coefficient for the G channel. This is the compensation coefficient for channel B. This represents the average value of the R channel. This is the average value of channel B. This is the average value of the G channel. This indicates that the image to be processed will be converted to... The maximum value of the Y channel after the channel.
[0049] Step C5. Adjust the pixel values of each pixel in the image to be processed using compensation coefficients based on the diagonal relationship: Where Scale(•) represents the normalization function (Min-Max Scaling), i.e. , This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed, and X represents the pixel value after normalization. This represents the minimum value of the pixel after normalization, which is set to 0 here; This represents the maximum value of the pixel after normalization, which is set to 255 here.
[0050] Step S540. If the first ratio is less than or equal to the first threshold and the second ratio is less than or equal to the second threshold, then use the histogram equalization translation algorithm to perform white balance correction on the to-be-processed image.
[0051] When the first ratio is less than or equal to the first threshold and the second ratio is less than or equal to the second threshold, the overall picture is too bright and seriously color-biased. The specific correction steps are as follows: Step D1. Calculate the histogram peak positions of the three channels of the to-be-processed image 、 、 respectively, and sort them in ascending order.
[0052] Step D2. Correct the smaller and larger color channels according to the peak difference: In the formula, is the histogram peak position of the channel of the to-be-processed image, is the histogram peak position of the channel of the to-be-processed image, is the histogram peak position of the channel of the to-be-processed image, 表示待处理图像中像素点R通道的原始像素值, represents the original pixel value of the B channel of the pixel point in the to-be-processed image, represents the final pixel value of the R channel of the pixel point in the to-be-processed image, 表示待处理图像中像素点B通道的最终像素值。
[0053] The "larger and smaller" in this step refers to the largest and smallest among the 、 、 three channels sorted in ascending order in Step D1. Taking R < G < B as an example, the smaller color channel is R, the larger color channel is B, and the peak difference is calculated by (g_max - r_max) and (g_max - b_max) in the formula.
[0054] In some embodiments, the adaptive white balance method further includes: before statistically calculating the pixel distribution histograms of each channel of the to-be-processed image, downsampling the to-be-processed image.
[0055] For example, the format of the image to be processed is changed from 7680 (W) × 4320 (H) × 3 (Channels) to 1920 (W) × 1080 (H) × 3 (Channels). The downsampling process reduces the number of pixel values, thereby improving the efficiency of subsequent histogram calculation.
[0056] The method described in this embodiment is simple, effective, versatile, and robust, applicable to complex scenes with varying degrees of brightness and color cast. This method is not only suitable for processing 8K images but also compatible with 4K, 1080P, and other formats. Compared to commonly used automatic white balance algorithms, this method introduces frequency information from each color channel as a priori judgment, enabling adaptive selection of different algorithms and achieving white balance more efficiently and accurately.
[0057] The method in this embodiment is applicable to 8K image datasets with complex scenes exhibiting varying degrees of brightness and color cast (example images are shown). Figure 2 , Figure 3 , Figure 4 and Figure 5 The test was conducted on (as shown). The white balance correction effect is as follows: Figure 6 , Figure 7 , Figure 8 and Figure 9 As shown, the method in this embodiment has a very wide range of applications and has achieved good white balance effects in different types of scenarios, thus improving the visual perception of the human eye.
[0058] The second aspect of this embodiment provides an adaptive white balance device. For example... Figure 10 As shown, the adaptive white balance device includes an image acquisition module, a histogram statistics module, a first calculation module, a second calculation module, and a white balance correction module.
[0059] An image acquisition module is used to acquire an image to be processed, wherein the image to be processed is in RGB format. For a detailed description of the image acquisition module, please refer to the description of step S100.
[0060] The histogram statistics module is used to calculate the pixel distribution histogram for each channel of the image to be processed. For a detailed description of the histogram statistics module, please refer to the description of step S200.
[0061] The first calculation module is used to calculate the proportion of pixels in the image to be processed whose brightness values are below a preset brightness threshold, denoted as the first proportion. For a detailed description of the first calculation module, please refer to the description of step S300.
[0062] The second calculation module is used to calculate the proportion of overlapping pixels in the R, G, and B channels of the image to be processed, denoted as the second proportion. For a detailed description of the second calculation module, please refer to the description of step S400.
[0063] The white balance correction module is used to determine a white balance algorithm based on the first ratio and the second ratio, and to perform white balance correction on the image to be processed using the white balance algorithm. For a detailed description of the white balance correction module, please refer to the description of step S500.
[0064] A third aspect of this embodiment provides an electronic device, the electronic device including a memory and a processor. The memory stores execution instructions; the processor executes the execution instructions stored in the memory, causing the processor to perform the adaptive white balance method described in the first aspect of this embodiment.
[0065] A fourth aspect of this embodiment provides a computer-readable storage medium storing executable instructions, which, when executed by a processor, are used to implement the adaptive white balance method described in the first aspect of this embodiment.
[0066] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.
Claims
1. An adaptive white balance method, characterized in that, include: Acquire the image to be processed, wherein the image to be processed is in RGB format; Statistically analyze the pixel distribution histogram of each channel of the image to be processed; The proportion of pixels in the image to be processed whose brightness values are below a preset brightness threshold is calculated and denoted as the first proportion. Calculate the ratio of the overlapping area of the pixel distribution histograms of the R, G, and B channels in the image to be processed, and denote it as the second ratio; The white balance algorithm is determined based on the first ratio and the second ratio, and the white balance algorithm is used to perform white balance correction on the image to be processed. The white balance algorithm is determined based on the first ratio and the second ratio, and the white balance algorithm is used to correct the white balance of the image to be processed, including: If the first ratio is greater than the first threshold and the second ratio is greater than the second threshold, then the image to be processed is white balance corrected by the truncation method, and the truncation threshold of the truncation process is the first threshold. If the first ratio is greater than the first threshold and the second ratio is less than or equal to the second threshold, then the QCGP algorithm is used to perform white balance correction on the image to be processed. If the first ratio is less than or equal to the first threshold and the second ratio is greater than the second threshold, then the white balance of the image to be processed is corrected by a mapping process, and the mapping threshold of the mapping process is the first threshold. If the first ratio is less than or equal to the first threshold and the second ratio is less than or equal to the second threshold, then the histogram equalization translation algorithm is used to perform white balance correction on the image to be processed.
2. The adaptive white balance method according to claim 1, characterized in that, The adaptive white balance method further includes: Before calculating the pixel distribution histogram of each channel of the image to be processed, the image to be processed is downsampled.
3. The adaptive white balance method according to claim 1, characterized in that, The image to be processed is subjected to white balance correction using a truncation method. The truncation threshold for the truncation process is the first threshold, including: The image to be processed is Space conversion to Space, computation Calculate the mean and variance of the variance. The mean and variance, where, Indicates blue component information. Indicates the red component information; Pixels in the image to be processed that conform to a preset rule are identified as initial white reference points. The preset rule is as follows: In the formula, for The mean, for The mean, for variance for The variance; Use the points with the highest brightness values (5% to 15%) of the initial white reference points as the final white reference points. Calculate the average value of the R, G, and B channels of the final white reference point; Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is as follows: In the formula, This is the compensation coefficient for the R channel. This is the compensation coefficient for the G channel. This is the compensation coefficient for channel B. This represents the average value of the R channel. This is the average value of channel B. This is the average value of the G channel. This indicates that the image to be processed will be converted to... The maximum value of the Y channel after the channel; Based on the diagonal relationship, the pixel values of each pixel in the image to be processed are adjusted using a compensation coefficient: In the formula, Clip(•) represents the cutoff function, i.e. , This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
4. The adaptive white balance method according to claim 1, characterized in that, The QCGP algorithm is used to perform white balance correction on the image to be processed, including: Calculate the maximum pixel value and the first transformation coefficient of the image to be processed. The formula for calculating the first transformation coefficient is as follows: In the formula, The first transformation coefficient, The maximum pixel value in the R channel of the image to be processed. The maximum pixel value in the B channel of the image to be processed. The maximum pixel value of the image to be processed in the G channel; Calculate the average pixel value of the image to be processed and the second transform coefficient. The formula for calculating the second transform coefficient is as follows: In the formula, These are the second transformation coefficients. The average pixel value of the image to be processed in the R channel. The average pixel value of the image to be processed in the B channel. The average pixel value of the image to be processed in the G channel; Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is as follows: In the formula, Represents the second-order compensation coefficient of the R channel. Represents the first-order compensation coefficient of the R channel. This represents the second-order compensation coefficient of the G channel. This represents the first-order compensation coefficient of the G channel. This represents the second-order compensation coefficient for channel B. This represents the first-order compensation coefficient for channel B; Adjust the pixel values of each pixel in the image to be processed according to the compensation coefficient: In the formula, This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
5. The adaptive white balance method according to claim 1, characterized in that, The image to be processed is subjected to white balance correction using a mapping processing method. The mapping threshold of the mapping processing is the first threshold, including: The image to be processed is Space conversion to Space, computation Calculate the mean and variance of the variance. The mean and variance, where, Indicates blue component information. Indicates the red component information; Pixels in the image to be processed that conform to a preset rule are identified as initial white reference points. The preset rule is as follows: In the formula, for The mean, for The mean, for variance for The variance; Use the points with the highest brightness values (5% to 15%) of the initial white reference points as the final white reference points. Calculate the average value of the R, G, and B channels of the final white reference point; Calculate the compensation coefficient for each channel in the image to be processed. The formula for calculating the compensation coefficient is as follows: In the formula, This is the compensation coefficient for the R channel. This is the compensation coefficient for the G channel. This is the compensation coefficient for channel B. This represents the average value of the R channel. This is the average value of channel B. This is the average value of the G channel. This indicates that the image to be processed will be converted to... The maximum value of the Y channel after the channel; Based on the diagonal relationship, the pixel values of each pixel in the image to be processed are adjusted using a compensation coefficient: Where Scale(•) represents the normalization function, i.e. , This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the G channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the G channel in the image to be processed. This represents the final pixel value of the B channel in the image to be processed, where X represents the pixel value after normalization. This represents the minimum value of a pixel after normalization. This represents the maximum value of a pixel after normalization.
6. The adaptive white balance method according to claim 1, characterized in that, The image to be processed is white balance corrected using a histogram equalization translation algorithm, including: Calculate the images to be processed separately , , The peak positions of the histograms for the three channels are sorted in ascending order; Correcting color channels that are too small or too large based on peak difference: In the formula, Image to be processed The peak position of the channel's histogram. Image to be processed The peak position of the channel's histogram. Image to be processed The peak position of the channel's histogram. This represents the original pixel value of the R channel in the image to be processed. This represents the original pixel value of the B channel in the image to be processed. This represents the final pixel value of the R channel in the image to be processed. This represents the final pixel value of the B channel of a pixel in the image to be processed.
7. An adaptive white balance device, characterized in that, include: An image acquisition module is used to acquire an image to be processed, wherein the image to be processed is in RGB format; The histogram statistics module is used to calculate the pixel distribution histogram of each channel of the image to be processed; The first calculation module is used to calculate the proportion of pixels in the image to be processed whose brightness values are below a preset brightness threshold, denoted as the first proportion. The second calculation module is used to calculate the ratio of the overlapping area of the pixel distribution histograms of the three channels R, G, and B in the image to be processed, denoted as the second ratio; The white balance correction module is used to determine the white balance algorithm according to the first ratio and the second ratio, and to perform white balance correction on the image to be processed using the white balance algorithm. The white balance algorithm is determined based on the first ratio and the second ratio, and the white balance algorithm is used to correct the white balance of the image to be processed, including: If the first ratio is greater than the first threshold and the second ratio is greater than the second threshold, then the image to be processed is white balance corrected by the truncation method, and the truncation threshold of the truncation process is the first threshold. If the first ratio is greater than the first threshold and the second ratio is less than or equal to the second threshold, then the QCGP algorithm is used to perform white balance correction on the image to be processed. If the first ratio is less than or equal to the first threshold and the second ratio is greater than the second threshold, then the white balance of the image to be processed is corrected by a mapping process, and the mapping threshold of the mapping process is the first threshold. If the first ratio is less than or equal to the first threshold and the second ratio is less than or equal to the second threshold, then the histogram equalization translation algorithm is used to perform white balance correction on the image to be processed.
8. An electronic device, characterized in that, include: The memory stores execution instructions; as well as A processor that executes execution instructions stored in the memory, causing the processor to perform the adaptive white balance method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores execution instructions, which, when executed by a processor, are used to implement the adaptive white balance method according to any one of claims 1 to 6.