Non-light source estimation AWB method and system based on color histogram
Through the non-light source estimation AWB method based on color histograms, RGB chromaticity range judgment is used to perform histogram matching, stretching or translation processing, which solves the problems of poor adaptability and inaccurate color correction of traditional light source estimation algorithms in multi-light source scenarios. It achieves a wider range of white balance applicable scenes and more efficient image processing effects.
Patent Information
- Application Number
- CN202111158657.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-30
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-09-30
AI Technical Summary
Traditional automatic white balance algorithms based on light source estimation have poor adaptability and inaccurate color correction in multi-light source scenarios, and algorithms based on deep convolutional neural networks are complex and require high hardware.
The non-light source estimation AWB method based on color histogram is adopted, and the histogram matching, stretching or translation processing is performed through RGB chromaticity range judgment to estimate the white balance of the image, and the consistency of the color channel histogram is used for white balance correction to avoid Light source estimation complexity and hardware requirements.
It improves the processing effect of automatic white balance of images under multiple light sources, expands the applicable scenes of white balance, solves the problems of poor scene adaptability and inaccurate color correction of traditional algorithms, and reduces algorithm complexity and hardware requirements.
Smart Images

Figure CN113850878B
Abstract
Description
Technical Field
[0001] The invention relates to the field of image processing, and more particularly to a non-light source estimation AWB method and system based on a color histogram. Background Art
[0002] The human visual system has the characteristic of color constancy, so human observation of objects is not affected by light sources. However, the color of objects presented by the sensor is different under different light sources, which may be blue under a clear sky and red under candlelight. In order to eliminate the influence of light sources on image sensor imaging and simulate the color constancy of the human visual system, a white balance algorithm is used to restore images under various color temperatures.
[0003] The common automatic AWB based on light source estimation is more suitable for the case of a single light source, but under multiple light sources, if the single light source algorithm is still used to estimate the light source in a scene, it cannot effectively correct the white balance of the image; the white balance algorithm based on deep convolutional neural network can effectively solve the problems of multiple light sources and uneven distribution of light sources in the image scene, but this type of algorithm requires a large amount of image data set, the algorithm is complex and has high hardware requirements; but the white balance algorithm based on histogram processing does not need to estimate the light source and the algorithm complexity is low. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a non-light source estimation AWB method and system based on color histogram, which can solve the problems of poor scene adaptability and inaccurate color correction of traditional automatic white balance algorithms based on light source estimation, and can improve the processing effect of automatic white balance of images under multiple light sources.
[0005] To achieve the above object, the present invention adopts the following technical solution:
[0006] A non-light source estimation AWB method based on color histogram comprises the following steps:
[0007] Get the original image and determine the RGB chromaticity range of the color histogram;
[0008] If the RGB chromaticity range is greater than the preset value, a histogram matching process is performed, and the gain coefficient when the overlapping area of the RGB channels is the largest is calculated, and then a linear process is used to correct the white balance of the image;
[0009] If the RGB chromaticity range is less than the preset value, a histogram similarity judgment is performed. If the similarity is less than the preset value, a stretching process is performed by adjusting the hue range of the color histogram. If the similarity is greater than the preset value, a translation process is performed.
[0010] Furthermore, the chromaticity range judgment of the color histogram of the image is specifically as follows: statistics are performed on the grayscale levels and pixel distributions of the three RGB channels, each channel is divided into four containers (0-63, 64-127, 128-191, 192-255), and then the four intervals of each channel are combined to obtain a feature vector containing 64 elements and used for feature matching, and different weights are assigned to each interval of each channel according to actual conditions.
[0011] Furthermore, the histograms of the R channel and the B channel of the image with a wide RGB chromaticity range are matched to the histogram of the G channel respectively, and the consistency of the color channel histograms is used to estimate the white balance of the image, as follows:
[0012] Calculate the channel histogram of R and G channels, where h C [n] represents the channel histogram, C represents the R, G, and B channels, and W and H represent the width and height of the image respectively.
[0013]
[0014] Then calculate the cumulative histogram S of the R and G channels C :
[0015]
[0016] Further, the stretching process is specifically as follows: two thresholds U and L are defined respectively, U is the maximum pixel value of the color histogram or percentile of the input image, L is the minimum pixel value in the color histogram of the input image or the minimum pixel value of the percentile, and the calculation formulas of U and L are expressed as follows:
[0017]
[0018] Calculate the difference between U and L. If the difference is greater than the threshold Th, it indicates that the grayscale distribution range of the image is large.
[0019] Furthermore, the gain coefficient when the channel overlap area is the largest is calculated, and then the white balance of the image is corrected using linear processing, specifically as follows: the images with different U and L values in the image set are calculated, U and L are set to be higher than the values of the other 99% pixels and lower than the values of the other 99% pixels, respectively, and a threshold Th is set for them. For images greater than the threshold Th, the chromaticity value of the output pixel needs to be calculated according to the following formula:
[0020]
[0021] In the formula, represents the output value of the picture pixel, represents the input value of the picture pixel, and R is the output chromaticity range.
[0022] Furthermore, the determination of the similarity of the RGB color channels is as follows:
[0023] The grayscale levels of each channel's histogram from 0 to 255 are divided into four intervals, and then the number of pixels in each interval is calculated; if the ratio of two or more intervals is greater than the set maximum threshold Th_max or less than the minimum threshold Th_min, it indicates that the histogram of the channel is too different from the histogram of the G channel, that is, the presence of a large number of saturated pixels in the image will cause the histogram matching algorithm to be over-corrected, and the histogram matching algorithm needs to be improved by channel shifting.
[0024] Furthermore, the translation process is specifically as follows:
[0025] The overlapping area is obtained by summing from level 0 to level 255. The formula for calculating the overlapping area of the RGB channel histogram is expressed as:
[0026]
[0027] Where H represents the overlapping area of the color histograms of the r, g, and b channels. The overlapping area originates from the intersection of all gray levels of the three color channels. The calculation formula for the maximum value of the overlapping area is expressed as:
[0028] H max =max(H r (k r ), H g (k g ), H b (k b ))
[0029] If the overlap area H reaches its maximum value, the gain factor k r , k g and k b becomes the expected value; that is, when the color histograms of the r, g, and b channels have the closest features and the smallest differences, the white balance effect is best.
[0030] A non-light source estimation AWB system based on color histogram comprises a processor, a memory and a computer program stored in the memory. When the processor executes the computer program, the steps in the AWB method described above are specifically performed.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] 1. The present invention can solve the problems of poor scene adaptability and inaccurate color correction of the traditional automatic white balance algorithm based on light source estimation, and can also improve the processing effect of automatic white balance of images under multiple light sources.
[0033] 2. The present invention can improve the problem that the traditional AWB based on light source estimation has poor effect when processing multi-light source images, and the white balance is applicable to a wider range of scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 is a flow chart of the method of the present invention;
[0035] Figure 2 is the distribution result of the RGB channels of the image after the histogram algorithm is processed in one embodiment of the present invention;
[0036] Figure 3 This is the test comparison result between the present invention and the traditional light source estimation method. DETAILED DESCRIPTION
[0037] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0038] Please refer to Figure 1 The present invention provides a non-light source AWB estimation method based on color histogram, comprising the following steps:
[0039] Get the original image and determine the RGB chromaticity range of the color histogram;
[0040] If the RGB chromaticity range is greater than the preset value, a histogram matching process is performed, and the gain coefficient when the overlapping area of the RGB channels is the largest is calculated, and then a linear process is used to correct the white balance of the image;
[0041] If the RGB chromaticity range is less than the preset value, the histogram similarity judgment is performed. If the similarity is less than the preset value, the stretching process is performed. By adjusting the hue range of the color histogram, if the similarity is greater than the preset value, the translation process is performed. This effectively avoids the situation where the monochrome area of the image is destroyed and the hue information is adjusted too much, so that the image processed by the histogram algorithm can adjust a wider color temperature range.
[0042] refer to Figure 2 In this embodiment, the processing of the input image to obtain the RGB channel histogram specifically includes performing channel determination processing on the input image and then obtaining a color histogram; the matching processing of the histogram of the image with a wide RGB chromaticity range is specifically as follows:
[0043] The grayscale levels and pixel distributions of the RGB channels are statistically analyzed, and each channel is divided into four containers (0-63, 64-127, 128-191, 192-255). Then, the four intervals of each channel are combined to obtain a feature vector containing 64 elements for feature matching. The histograms of the R and B channels of the image are matched to the histogram of the G channel respectively, and the consistency of the color channel histograms is used to estimate the white balance of the image.
[0044] In this embodiment, for an image with a wide RGB chromaticity range, the histograms of the R channel and the B channel of the image are matched to the histogram of the G channel respectively, and the consistency of the color channel histograms is used to estimate the white balance of the image, as follows:
[0045] Calculate the channel histogram of R and G channels, where h C [n] represents the channel histogram, C represents the R, G, and B channels, and W and H represent the width and height of the image respectively.
[0046]
[0047] Then calculate the cumulative histogram S of the R and G channels C :
[0048]
[0049] In this embodiment, the histogram of an image with a narrow RGB chromaticity range is stretched as follows: two thresholds U and L are defined respectively, where U is the maximum pixel value of the color histogram or percentile of the input image, and L is the minimum pixel value in the color histogram of the input image or the minimum pixel value of the percentile. The calculation formulas of U and L are expressed as follows:
[0050]
[0051] Calculate the difference between U and L. If the difference is greater than the threshold Th, it indicates that the grayscale distribution range of the image is large.
[0052] In this embodiment, the gain coefficient is calculated when the channel overlap area is the largest, and then the linear processing is used to correct the white balance of the image, specifically as follows: the images with different U and L values in the image set are calculated, and U and L are set to values higher than and lower than the other 99% of the pixels, respectively, and a threshold Th is set for them. For images greater than the threshold Th, the chromaticity value of the output pixel needs to be calculated according to the following formula:
[0053]
[0054] In the formula, represents the output value of the picture pixel, represents the input value of the picture pixel, and R is the output chromaticity range.
[0055] In this embodiment, the determination of the similarity of the RGB color channels is as follows:
[0056] The grayscale levels of each channel's histogram from 0 to 255 are divided into four intervals, and then the number of pixels in each interval is calculated; if the ratio of two or more intervals is greater than the set maximum threshold Th_max or less than the minimum threshold Th_min, it indicates that the histogram of the channel is too different from the histogram of the G channel, that is, the presence of a large number of saturated pixels in the image will cause the histogram matching algorithm to be over-corrected, and the histogram matching algorithm needs to be improved by channel shifting.
[0057] In this embodiment, the translation process is specifically as follows:
[0058] The overlapping area is obtained by summing from level 0 to level 255. The formula for calculating the overlapping area of the RGB channel histogram is expressed as:
[0059]
[0060] Where H represents the overlapping area of the color histograms of the r, g, and b channels. The overlapping area originates from the intersection of all gray levels of the three color channels. The calculation formula for the maximum value of the overlapping area is expressed as:
[0061] H max =max(H r (k r ), H g (k g ), H b (k b ))
[0062] If the overlap area H reaches its maximum value, the gain factor k r , k g and k b becomes the expected value; that is, when the color histograms of the r, g, and b channels have the closest features and the smallest differences, the white balance effect is best.
[0063] In this embodiment, a non-light source estimation AWB system based on color histogram is also provided, including a processor, a memory, and a computer program stored in the memory. When the processor executes the computer program, the steps in the AWB method described above are specifically performed.
[0064] from Figure 3 It can be seen that, compared with the traditional light source estimation method, this method can improve the problem that the AWB algorithm based on light source estimation has poor effect when processing multi-light source images. The present invention is more accurate in processing the white balance of the image and can process richer image scenes.
[0065] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0066] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0067] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0068] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0069] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.
Claims
1. A non-light source estimation AWB method based on color histogram, It is characterized in that The following steps are involved: Get the original image and determine the RGB chromaticity range of the color histogram; If the RGB chromaticity range is greater than the preset value, a histogram matching process is performed, and the gain coefficient when the overlapping area of the RGB channels is the largest is calculated, and then the white balance of the image is corrected using linear processing; for images with a wider RGB chromaticity range, the histograms of the R channel and the B channel of the image are matched to the histogram of the G channel respectively, and the consistency of the color channel histograms is used to estimate the white balance of the image, as follows: Calculate the channel histogram of R and G channels, where h c [n] represents the channel histogram, W and H are the width and height of the image respectively Then calculate the cumulative histogram S of the R and G channels c : If the RGB chromaticity range is less than the preset value, the histogram similarity judgment is performed. If the similarity is less than the preset value, stretching processing is performed by adjusting the hue range of the color histogram. If the similarity is greater than the preset value, translation processing is performed; The obtaining of the original image and the determination of the RGB chromaticity range of the color histogram are specifically as follows: statistics are taken on the grayscale levels and pixel distributions of the three RGB channels, each channel is divided into four containers 0-63, 64-127, 128-191, and 192-255, and then the four intervals of each channel are combined to obtain a feature vector containing 64 elements for feature matching, and different weights are assigned to each interval of each channel according to actual conditions; The stretching process is specifically as follows: two thresholds U and L are defined respectively, where U is the maximum pixel value or the maximum pixel value of the percentile in the color histogram of the input image, and L is the minimum pixel value or the minimum pixel value of the percentile in the color histogram of the input image. The calculation formulas of U and L are expressed as follows: Calculate the difference between U and L. If the difference is greater than the threshold Th, it indicates that the grayscale distribution range of the image is large; The method of calculating the gain coefficient when the overlapping area of the RGB channels is the largest and then using linear processing to correct the white balance of the image is as follows: Calculate the images with different U and L values in the image set, set U and L to values higher than and lower than the other 99% pixels, respectively, and set a threshold Th for them. For images greater than the threshold Th, the chromaticity value of the output pixel needs to be calculated according to the following formula: Where C out Represents the output value of the image pixel, C in Represents the input value of the image pixel, and R is the output chromaticity range; The histogram similarity judgment is performed as follows: Divide the grayscale level of each channel histogram from 0 to 255 into 4 intervals, and then calculate the number of pixels in each interval; if the ratio of two or more intervals is greater than the set maximum threshold Th_max or less than the minimum threshold Th_min, it means that the histogram of the channel is too different from the histogram of the G channel, that is, there are a large number of saturated pixels in the image, which will cause the histogram matching algorithm to be over-corrected, and the histogram matching algorithm needs to be improved by channel translation; The translation process is specifically as follows: The overlapping area is obtained by summing from level 0 to level 255. The formula for calculating the overlapping area of the RGB channel histogram is expressed as: Where H represents the overlapping area of the color histograms of the r, g, and b channels. The overlapping area originates from the intersection of all gray levels of the three color channels. The calculation formula for the maximum value of the overlapping area is expressed as: H max =max(H r (k r ),H g (k g ),H b (k b )) If the overlap area H reaches its maximum value, the gain factor k r , k g and k b becomes the expected value; that is, when the color histograms of the r, g, and b channels have the closest features and the smallest differences, the white balance effect is best.
2. A non-light source estimation AWB system based on color histogram, It is characterized in that The method comprises a processor, a memory and a computer program stored in the memory, wherein when the processor executes the computer program, the steps in the AWB method according to claim 1 are specifically performed.
