CN116489330A - Self-adaptive white balance method and device, electronic equipment and storage medium - Google Patents

Self-adaptive white balance method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116489330A
CN116489330A CN202310574991.3A CN202310574991A CN116489330A CN 116489330 A CN116489330 A CN 116489330A CN 202310574991 A CN202310574991 A CN 202310574991A CN 116489330 A CN116489330 A CN 116489330A
Authority
CN
China
Prior art keywords
image
processed
channel
max
pixel
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310574991.3A
Other languages
Chinese (zh)
Inventor
刘征
郑慧明
姜春桐
谢雯妮
刘洁旭
赵周丽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sichuan Xinshi Chuangwei Ultra High Definition Technology Co ltd
Original Assignee
Sichuan Xinshi Chuangwei Ultra High Definition Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sichuan Xinshi Chuangwei Ultra High Definition Technology Co ltd filed Critical Sichuan Xinshi Chuangwei Ultra High Definition Technology Co ltd
Priority to CN202310574991.3A priority Critical patent/CN116489330A/en
Publication of CN116489330A publication Critical patent/CN116489330A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/64Circuits for processing colour signals
    • H04N9/73Colour balance circuits, e.g. white balance circuits or colour temperature control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/40Image enhancement or restoration using histogram techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/90Dynamic range modification of images or parts thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Processing Of Color Television Signals (AREA)

Abstract

The invention discloses a self-adaptive white balance method, a device, electronic equipment and a storage medium, and belongs to the technical field of image processing. The self-adaptive white balance method comprises the following steps: acquiring an image to be processed, wherein the image to be processed is in an RGB format; counting pixel distribution histograms of all channels of the image to be processed; calculating the proportion of pixel points with brightness values below a preset brightness threshold value in the image to be processed, and marking the proportion as a first proportion; calculating the proportion of overlapping pixel points of the R, G, B channels in the image to be processed, and marking the proportion as a second proportion; and determining a white balance algorithm according to the first proportion and the second proportion, and carrying out white balance correction on the image to be processed by utilizing the white balance algorithm. The invention introduces the frequency information of each color channel as prior judgment, and the self-adaptive selection algorithm realizes white balance correction.

Description

Self-adaptive white balance method and device, electronic equipment and storage medium
Technical Field
The invention belongs to the technical field of image processing, and particularly relates to a self-adaptive white balance method, a device, electronic equipment and a storage medium.
Background
The automatic white balance algorithm aims at analyzing the picture signals and simulating the constancy of human perception of colors, so that the influence of light source colors on imaging is overcome, and the restoration of the true color information of the picture is an important ring in the digital image signal processing flow. The automatic white balance algorithms at the present stage can be divided into two categories: hypothesis-based algorithms and histogram-based algorithms.
The hypothesis-based algorithm makes a hypothesis for the whole color or the brightest pixel of the picture according to the color information of the picture, and mainly comprises a gray world method, a perfect reflection method, a QCGP method and a dynamic threshold method. The gray world approach is simpler, but it makes the assumption that the "RGB channel pixel average is gray" for color rich pictures, and fails for images where there are a large number of monochromatic blocks. The perfect reflection method and the dynamic threshold method make assumptions about white points in an original image through analysis and calculation, but larger deviation can occur in color correction when the brightest point in the original image is not the white point or the original image does not have the white point. The QCGP method (Quadratic Combining Grey-World Perfect-Reflection Resumption) integrates and improves gray World and Perfect reflection assumption, and solves compensation coefficients of all channels by defining a color equation; although this method effectively improves the white balance effect, it still fails to accurately restore color for images that are entirely dark and have a large number of monochromatic patches.
The histogram-based algorithm is mainly based on histogram translation and matching, and ensures that the overlapping area of the histogram-based algorithm reaches the maximum by processing different channels, so that the method can be effectively applied to images with serious color bias (the overlapping area of the histograms of the three channels is extremely small, and the overall color tone is obviously biased to one color in R, G and B). However, for the shot of 8K ultra high definition cameras, this approach still has two challenges: firstly, the algorithm complexity, the pixel quantity of the 8K image is extremely large, and the statistics of the global histogram can bring extremely large time burden; secondly, the randomness of the scene, and for images with slight color cast or low brightness, the center position or shape of the histogram of different channels is adjusted, so that the picture loses color details.
Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a self-adaptive white balance method, a device, electronic equipment and a storage medium.
The aim of the invention is realized by the following technical scheme:
according to a first aspect of the present invention, an adaptive white balance method comprises:
acquiring an image to be processed, wherein the image to be processed is in an RGB format;
counting pixel distribution histograms of all channels of the image to be processed;
calculating the proportion of pixel points with brightness values below a preset brightness threshold value in the image to be processed, and marking the proportion as a first proportion;
calculating the proportion of overlapping pixel points of the R, G, B channels in the image to be processed, and marking the proportion as a second proportion;
and determining a white balance algorithm according to the first proportion and the second proportion, and carrying out white balance correction on the image to be processed by utilizing the white balance algorithm.
Further, the adaptive white balance method further includes:
the image to be processed is downsampled before the pixel distribution histogram of each channel of the image to be processed is counted.
Further, determining a white balance algorithm according to the first proportion and the second proportion, and performing white balance correction on the image to be processed by using the white balance algorithm, wherein the white balance correction comprises the following steps:
if the first proportion is larger than the first threshold value and the second proportion is larger than the second threshold value, white balance correction is carried out on the image to be processed by adopting a truncation processing method, and the truncation processing threshold value adopts the first threshold value;
if the first proportion is larger than the first threshold value and the second proportion is smaller than or equal to the second threshold value, adopting a QCGP algorithm to carry out white balance correction on the image to be processed;
if the first proportion is smaller than or equal to a first threshold value and the second proportion is larger than a second threshold value, white balance correction is carried out on the image to be processed by adopting a mapping processing method, and the mapping processing threshold value adopts the first threshold value;
and if the first proportion is smaller than or equal to the first threshold value and the second proportion is smaller than or equal to the second threshold value, performing white balance correction on the image to be processed by adopting a histogram equalization/translation algorithm.
Further, white balance correction is performed on the image to be processed by adopting a truncation processing method, and a threshold value of the truncation processing adopts a first threshold value, which comprises the following steps:
converting an image to be processed from RGB space to YC b C r Space, calculate C b Mean and variance of (C) r Mean and variance of (C), where C b Representing red component information, C r Representing blue component information;
determining pixel points meeting preset rules in an image to be processed as initial white reference points, wherein the preset rules are as follows:
|C b -(M b +D b ×sign(M b ))|<r×D b
|C r -(r×M r +D r ×sign(M r ))|<r×D b
wherein M is b Is C b Mean value of M r Is C r Mean value of D b Is C b Variance of D r Is C r Is a variance of (2);
taking the point 5% -15% before the initial white reference point clock brightness value as the final white reference point;
calculating an average value of R, G, B three channel pixels of the final white reference point;
calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
gain R =Y max /R avgw
gain G =Y max /G avgw
gain B =Y max /B avgw
in the gain R For compensation coefficient of R channel, gain G For compensation factor of G channel, gain B For the compensation coefficient of B channel, R avgw Mean value of R channel, B avgw Mean of B channel, G avgw Mean of G channel, Y max Representing conversion of an image to be processed to YC b C r Maximum value of Y channel after channel;
according to the diagonal relation, the pixel value of each pixel point in the image to be processed is adjusted by using the compensation coefficient:
R′=Clip(gain R *R 0 )
G′=Clip(gain G *G 0 )
B′=Clip(gain B *B 0 )
in the formula, clip (. Cndot.) represents a truncated function, i.eR 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 The original pixel value of the pixel point B channel in the image to be processed is represented, R ' represents the final pixel value of the pixel point R channel in the image to be processed, G ' represents the final pixel value of the pixel point G channel in the image to be processed, and B ' represents the final pixel value of the pixel point B channel in the image to be processed.
Further, performing white balance correction on the image to be processed by adopting a QCGP algorithm, including:
calculating a maximum pixel value of an image to be processed and a first transformation coefficient, wherein the calculation formula of the first transformation coefficient is as follows:
K max =(R max +B max +G max )/3
wherein K is max R is the first transform coefficient max For the maximum pixel value of the image to be processed in the R channel, B max For the maximum pixel value of the image to be processed in the B channel, G max The maximum pixel value of the image to be processed in the G channel is obtained;
calculating an average pixel value of an image to be processed and a second transformation coefficient, wherein a calculation formula of the second transformation coefficient is as follows:
K avg =(R avg +B avg +G avg )/3
wherein K is avg For the second transform coefficient, R avg For the average pixel value of the image to be processed in the R channel, B avg For the average pixel value of the image to be processed in the B channel, G avg The average pixel value of the image to be processed in the G channel is obtained;
calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
u R R avg 2 +v R R avg =K avg
u R R max 2 +v R R max =K max
u G G avg 2 +v G G avg =K avg
u G G max 2 +v G G max =K max
u B B avg 2 +v B B avg =K avg
u B B max 2 +v B B max =K max
wherein u is R Representing the second order compensation coefficient of the R channel, v R Represents the first-order compensation coefficient of the R channel, u G Representing the second order compensation coefficient of the G channel, v G Represents the first order compensation coefficient of the G channel, u B Representing the second order compensation coefficient of the B channel, v B Representing a first-order compensation coefficient of the B channel;
according to the compensation coefficient, adjusting the pixel value of each pixel point in the image to be processed:
R′=u R R 0 2 +v R R 0
G′=u G G 0 2 +v G G 0
B′=u B B 0 2 +v B B 0
wherein R is 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 The original pixel value of the pixel point B channel in the image to be processed is represented, R ' represents the final pixel value of the pixel point R channel in the image to be processed, G ' represents the final pixel value of the pixel point G channel in the image to be processed, and B ' represents the final pixel value of the pixel point B channel in the image to be processed.
Further, white balance correction is performed on the image to be processed by adopting a mapping processing method, and a first threshold is adopted as a threshold of the mapping processing, including:
converting an image to be processed from RGB space to YC b C r Space, calculate C b Mean and variance of (C) r Mean and variance of (C), where C b Representing red component information, C r Representing blue component information;
determining pixel points meeting preset rules in an image to be processed as initial white reference points, wherein the preset rules are as follows:
|C b -(M b +D b ×sign(M b ))|<r×D b
|C r -(r×M r +D r ×sign(M r ))|<r×D b
wherein M is b Is C b Mean value of M r Is C r Mean value of D b Is C b Variance of D r Is C r Is a variance of (2);
taking the point 5% -15% before the initial white reference point clock brightness value as the final white reference point;
calculating an average value of R, G, B three channel pixels of the final white reference point;
calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
gain R =Y max /R avgw
gain G =Y max /G avgw
gain B =Y max /B avgw
in the gain R For compensation coefficient of R channel, gain G For compensation factor of G channel, gain B For the compensation coefficient of B channel, R avgw Mean value of R channel, B avgw Mean of B channel, G avgw Mean of G channel, Y max Representing conversion of an image to be processed to YC b C r Maximum value of Y channel after channel;
according to the diagonal relation, the pixel value of each pixel point in the image to be processed is adjusted by using the compensation coefficient:
R′=Scale(gain R *R 0 )
G′=Scale(gain G *G 0 )
B′=Scale(gain B *B 0 )
wherein Scale (·) represents the normalization function, i.eR 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 Representing the original pixel value of a pixel point B channel in the image to be processed, wherein R ' represents the final pixel value of a pixel point R channel in the image to be processed, G ' represents the final pixel value of a pixel point G channel in the image to be processed, B ' represents the final pixel value of a pixel point B channel in the image to be processed, X represents the pixel value of normalization processing, X min Representing the minimum value, X, of the normalized pixel max Representing the maximum value of the normalized pixel.
Further, the method for correcting the white balance of the image to be processed by adopting a histogram equalization/translation algorithm comprises the following steps:
respectively calculating the peak positions of histograms of three channels of the image R, G, B to be processed, and sequencing the three channels according to the sequence from small to large;
correcting smaller and larger color channels according to the peak value difference value:
R′=R 0 +g max -r max
B′=B 0 +g max -b max
wherein r is max G is the histogram peak position of R channel of the image to be processed max B for the histogram peak position of the G channel of the image to be processed max R is the position of the peak value of the histogram of the B channel of the image to be processed 0 Representing the original pixel value of a pixel point R channel in an image to be processed, B 0 The original pixel value of the pixel point B channel in the image to be processed is represented, R 'represents the final pixel value of the pixel point R channel in the image to be processed, and B' represents the final pixel value of the pixel point B channel in the image to be processed.
According to a second aspect of the present invention, an adaptive white balance device comprises:
the image acquisition module is used for acquiring an image to be processed, wherein the image to be processed is in an RGB format;
the histogram statistics module is used for counting pixel distribution histograms of all channels of the image to be processed;
the first calculation module is used for calculating the proportion of pixel points with brightness values below a preset brightness threshold value in the image to be processed, and marking the proportion as a first proportion;
the second calculation module is used for calculating the proportion of the overlapping pixel points of the R, G, B channels in the image to be processed, and marking the proportion as a second proportion;
and the white balance correction module is used for determining a white balance algorithm according to the first proportion and the second proportion and carrying out white balance correction on the image to be processed by utilizing the white balance algorithm.
According to a third aspect of the invention, an electronic device comprises:
a memory storing execution instructions; and
and a processor executing the execution instructions stored in the memory, so that the processor executes the adaptive white balance method according to the first aspect of the present invention.
According to a fourth aspect of the present invention, a computer readable storage medium has stored therein execution instructions which, when executed by a processor, are adapted to carry out the adaptive white balance method according to the first aspect of the present invention.
The beneficial effects of the invention are as follows:
(1) The existing white balance algorithm is only suitable for part of specific scenes (such as scene pictures with rich colors and scene pictures with brightest spots being white spots), or color detail information is easy to lose (such as histogram-based algorithm), so that the white balance algorithm has no universality for complex scenes, and large-scale failure or white balance correction errors can occur in the actual application of the complex scenes. The invention introduces the frequency information of each color channel as prior judgment, divides the original picture into four types according to the color distribution characteristics, sets a threshold mechanism and realizes white balance correction by a self-adaptive selection algorithm;
(2) Acquiring the histogram requires statistics of global information of the picture, and the complexity is too high for the data acquired by the 8K ultra-high definition camera. Because the influence of different sampling scales on the color distribution situation is very small, the invention designs the down-sampling pretreatment, reduces the pixel value of the picture, further improves the statistics and calculation efficiency of the histogram, and ensures that the application of the histogram information does not bring excessive time burden to the whole flow.
Drawings
FIG. 1 is a flow chart of an embodiment of an adaptive white balance method according to the present invention;
FIG. 2 is a first test picture;
FIG. 3 is a second test picture;
FIG. 4 is a test panel III;
FIG. 5 is a fourth test picture;
FIG. 6 is a first test image after performing a white balance process using the method of the present invention;
FIG. 7 is a second test image after white balancing by the method of the present invention;
FIG. 8 is a third test image after white balancing using the method of the present invention;
FIG. 9 is a fourth test image after white balancing using the method of the present invention;
fig. 10 is a block diagram of an adaptive white balance method according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments, and it is apparent that the described embodiments are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by a person skilled in the art without any inventive effort, are intended to be within the scope of the present invention, based on the embodiments of the present invention.
Referring to fig. 1 to 10, the present invention provides an adaptive white balance method, an adaptive white balance device, an electronic device, and a storage medium:
a first aspect of the present embodiment discloses an adaptive white balancing method. As shown in fig. 1, the adaptive white balance method includes steps S100 to S500. The following is a detailed description.
S100, obtaining an image to be processed, wherein the image to be processed is in an RGB format.
For example, the specification of the image to be processed is 7680 (W) ×4320 (H) ×3 (Channels).
And S200, counting pixel distribution histograms of all channels of the image to be processed.
And S300, calculating the proportion of pixel points with brightness values below a preset brightness threshold in the image to be processed, and marking the proportion as a first proportion.
The luminance value in step S300 refers to the sum of the total pixels of three channels passing through the image R, G, B and represents the overall luminance of the image, and in general, the larger the luminance, the higher the luminance.
And S400, calculating the proportion of the overlapping pixel points of the R, G, B channels in the image to be processed, and marking the proportion as a second proportion.
The execution order of the step S300 and the step S400 is not limited, that is, the step S300 and the step S400 may be executed simultaneously, the step S300 may be executed first, the step S400 may be executed second, and the step S400 may be executed first, and then the step S300 may be executed second.
S500, determining a white balance algorithm according to the first proportion and the second proportion, and carrying out white balance correction on the image to be processed by using the white balance algorithm.
In some embodiments, determining a white balance algorithm according to the first proportion and the second proportion, and performing white balance correction on the image to be processed by using the white balance algorithm, including:
and S510, if the first proportion is larger than a first threshold value and the second proportion is larger than a second threshold value, white balance correction is carried out on the image to be processed by adopting a truncation processing method, and the truncation processing threshold value adopts the first threshold value.
The first and second thresholds may be selected by testing of the large-scale dataset, for example, the first threshold may be 0.7 and the second threshold may be 0.15.
When the first proportion is larger than the first threshold value and the second proportion is larger than the second threshold value, the whole picture is dark and the color cast is not obvious, and the specific correction steps are as follows:
step A1 converting the image to be processed from RGB space to YC b C r Space, calculate C b Mean and variance of (C) r Mean and variance of (C), where C b Representing red component information, C r Representing blue component information.
A2, determining pixel points meeting preset rules in the image to be processed as initial white reference points, wherein the preset rules are as follows:
|C b -(M b +D b ×sign(M b ))|<r×D b
|C r -(r×M r +D r ×sign(M r ))|<r×D b
wherein M is b Is C b Mean value of M r Is C r Mean value of D b Is C b Variance of D r Is C r Is a variance of (c).
And step A3, taking the point 5% -15% before the initial white reference point clock brightness value as a final white reference point.
In some embodiments, the point 10% before the initial white reference o' clock luminance value may be taken as the final white reference point.
Step a4. Calculate the average of R, G, B three channel pixels of the final white reference point.
And step A5, calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
gain R =Y max /R avgw
gain G =Y max /G avgw
gain B =Y max /B avgw
in the gain R For compensation coefficient of R channel, gain G For compensation factor of G channel, gain B For the compensation coefficient of B channel, R avgw Mean value of R channel, B avgw Mean of B channel, G avgw Mean of G channel, Y max Representing conversion of an image to be processed to YC b C r Maximum value of Y channel after channel.
A6, according to the diagonal relation, adjusting the pixel value of each pixel point in the image to be processed by using the compensation coefficient:
R′=Clip(gain R *R 0 )
G′=Clip(gain G *G 0 )
B′=Clip(gain B *B 0 )
in the formula, clip (. Cndot.) represents a truncated function, i.eR 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representation ofOriginal pixel value B of pixel point G channel in image to be processed 0 The original pixel value of the pixel point B channel in the image to be processed is represented, R ' represents the final pixel value of the pixel point R channel in the image to be processed, G ' represents the final pixel value of the pixel point G channel in the image to be processed, and B ' represents the final pixel value of the pixel point B channel in the image to be processed.
And S520, if the first proportion is larger than a first threshold value and the second proportion is smaller than or equal to a second threshold value, adopting a QCGP algorithm to carry out white balance correction on the image to be processed.
When the first proportion is larger than the first threshold value and the second proportion is smaller than or equal to the second threshold value, the whole picture is dark and serious in color cast, and the specific correction steps are as follows:
step B1, calculating a maximum pixel value of an image to be processed and a first transformation coefficient, wherein the calculation formula of the first transformation coefficient is as follows:
K max =(R max +B max +G max )/3
wherein K is max R is the first transform coefficient max For the maximum pixel value of the image to be processed in the R channel, B max For the maximum pixel value of the image to be processed in the B channel, G max The maximum pixel value of the image to be processed in the G channel.
Step B2, calculating an average pixel value of the image to be processed and a second transformation coefficient, wherein the calculation formula of the second transformation coefficient is as follows:
K avg =(R avg +B avg +G avg )/3
wherein K is avg For the second transform coefficient, R avg For the average pixel value of the image to be processed in the R channel, B avg For the average pixel value of the image to be processed in the B channel, G avg The average pixel value of the image to be processed in the G channel.
And step B3, calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
u R R avg 2 +v R R avg =K avg
u R R max 2 +v R R max =K max
u G G avg 2 +v G G avg =K avg
u G G max 2 +v G G max =K max
u B B avg 2 +v B B avg =K avg
u B B max 2 +v B B max =K max
wherein u is R Representing the second order compensation coefficient of the R channel, v R Represents the first-order compensation coefficient of the R channel, u G Representing the second order compensation coefficient of the G channel, v G Represents the first order compensation coefficient of the G channel, u B Representing the second order compensation coefficient of the B channel, v B Representing the B-channel first order compensation coefficient.
Step B4. adjusts the pixel values of each pixel point in the image to be processed according to the compensation coefficient:
R′=u R R 0 2+v R R 0
G′=u G G 0 2+v G G 0
B′=u B B 0 2+v B B 0
wherein R is 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 The original pixel value of the pixel point B channel in the image to be processed is represented, R ' represents the final pixel value of the pixel point R channel in the image to be processed, G ' represents the final pixel value of the pixel point G channel in the image to be processed, and B ' represents the final pixel value of the pixel point B channel in the image to be processed.
And S530, if the first proportion is smaller than or equal to a first threshold value and the second proportion is larger than a second threshold value, performing white balance correction on the image to be processed by adopting a mapping processing method, wherein the mapping processing threshold value adopts the first threshold value.
When the first proportion is smaller than or equal to a first threshold value and the second proportion is larger than a second threshold value, the whole picture is bright and the color cast is not obvious, and the specific correction steps are as follows:
step C1. Converting the image to be processed from RGB space to YC b C r Space, calculate C b Mean and variance of (C) r Mean and variance of (C), where C b Representing red component information, C r Representing blue component information.
Determining pixel points meeting preset rules in an image to be processed as initial white reference points, wherein the preset rules are as follows:
|C b -(M b +D b ×sign(M b ))|<r×D b
|C r -(r×M r +D r ×sign(M r ))|<r×D b
wherein M is b Is C b Mean value of M r Is C r Mean value of D b Is C b Variance of D r Is C r Is a variance of (c).
Step C2. takes the point 5% -15% before the initial white reference o' clock luminance value as the final white reference point.
In some embodiments, the point 10% before the initial white reference o' clock luminance value may be taken as the final white reference point.
Step C3. calculates the average of R, G, B three channel pixels of the final white reference point.
And step C4, calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
gain R =Y max /R avgw
gain G =Y max /G avgw
gain B =Y max /B avgw
in the gain R For compensation coefficient of R channel, gain G For compensation factor of G channel, gain B For the compensation coefficient of B channel, R avgw Mean value of R channel, B avgw Mean of B channel, G avgw Mean of G channel, Y max Representing conversion of an image to be processed to YC b C r Maximum value of Y channel after channel.
Step C5., according to the diagonal relationship, adjusting the pixel value of each pixel point in the image to be processed by using the compensation coefficient:
R′=Scale(gain R *R 0 )
G′=Scale(gain G *G 0 )
B′=Scale(gain B *B 0 )
wherein Scale (·) represents the normalization function (Min-Max Scaling), i.eR0 represents the original pixel value of a pixel point R channel in the image to be processed, G 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 Representing an original pixel value of a pixel point B channel in the image to be processed, wherein R ' represents a final pixel value of a pixel point R channel in the image to be processed, G ' represents a final pixel value of a pixel point G channel in the image to be processed, B ' represents a final pixel value of a pixel point B channel in the image to be processed, and X represents a normalized pixel value; x is X min Representing the minimum value of the normalized pixel, here set to 0; x is X max The maximum value of the normalized pixel is shown, here set to 255.
S540, if the first proportion is smaller than or equal to a first threshold value and the second proportion is smaller than or equal to a second threshold value, performing white balance correction on the image to be processed by adopting a histogram equalization/translation algorithm.
When the first proportion is smaller than or equal to a first threshold value and the second proportion is smaller than or equal to a second threshold value, the whole picture is bright and the color cast is serious, and the specific correction steps are as follows:
step d1. The histogram peak positions of the three channels of the image R, G, B to be processed are calculated respectively and sorted in order from small to large.
Step D2. corrects smaller and larger color channels according to the peak difference:
R′=R 0 +g max -r max
B′=B 0 +g max -b max
wherein r is max G is the histogram peak position of R channel of the image to be processed max B for the histogram peak position of the G channel of the image to be processed max R is the position of the peak value of the histogram of the B channel of the image to be processed 0 Representing the original pixel value of a pixel point R channel in an image to be processed, B 0 The original pixel value of the pixel point B channel in the image to be processed is represented, R 'represents the final pixel value of the pixel point R channel in the image to be processed, and B' represents the final pixel value of the pixel point B channel in the image to be processed.
"bigger and smaller" in this step means that the three channels R, G, B in step D1 are largest and smallest in the order of small to large. Taking R < G < B as an example, the smaller color channel is R, the larger color channel is B, and the peak value difference is calculated by (g_max-r_max) and (g_max-b_max) in the formula.
In some embodiments, the adaptive white balance method further comprises: the image to be processed is downsampled before the pixel distribution histogram of each channel of the image to be processed is counted.
For example, the format of the image to be processed is changed from 7680 (W) x 4320 (H) x 3 (Channels) to 1920 (W) x 1080 (H) x 3 (Channels), and the down-sampling process reduces the pixel value, thereby improving the subsequent histogram calculation efficiency.
The method of the embodiment is simple and effective, has universality and robustness, and is suitable for complex scenes with different brightness degrees and color cast degrees. The method of the embodiment is not only suitable for processing 8K images, but also compatible with formats of 4K,1080P and the like. Compared with the common automatic white balance algorithm, the method of the embodiment introduces the frequency information of each color channel as the priori judgment, realizes the self-adaptive selection of different algorithms, and realizes the white balance more efficiently and accurately.
The method of the present embodiment tests on 8K picture datasets (example pictures are shown in fig. 2, 3, 4 and 5) with complex scenes of different shades and different color cast degrees. As shown in fig. 6, 7, 8 and 9, the application range of the method of the embodiment is extremely wide, and the white balance correction effect is better in different types of scenes, so that the visual sense of human eyes is improved.
A second aspect of the present embodiment provides an adaptive white balance device. As shown in fig. 10, 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.
The image acquisition module is used for acquiring an image to be processed, wherein the image to be processed is in an RGB format. For a specific description of the image acquisition module, reference may be made to the description of step S100.
And the histogram statistics module is used for counting pixel distribution histograms of all channels of the image to be processed. For a specific description of the histogram statistics module, reference may be made to the description of step S200.
The first calculating module is used for calculating the proportion of pixel points with brightness values below a preset brightness threshold value in the image to be processed, and marking the proportion as a first proportion. For a specific description of the first computing module, reference may be made to the description of step S300.
And the second calculation module is used for calculating the proportion of the overlapping pixel points of the R, G, B channels in the image to be processed and marking the proportion as a second proportion. For a specific description of the second computing module, reference may be made to the description of step S400.
And the white balance correction module is used for determining a white balance algorithm according to the first proportion and the second proportion and carrying out white balance correction on the image to be processed by utilizing the white balance algorithm. A specific description of the white balance correction module may refer to the description of the step S500.
A third aspect of the present embodiments provides an electronic device comprising a memory and a processor. The memory stores execution instructions; the processor executes the execution instructions stored in the memory, so that the processor executes the adaptive white balance method according to the first aspect of the present embodiment.
A fourth aspect of the present embodiment provides a computer-readable storage medium having stored therein execution instructions which, when executed by a processor, are configured to implement the adaptive white balance method according to the first aspect of the present embodiment.
The foregoing is merely a preferred embodiment of the invention, and it is to be understood that the invention is not limited to the form disclosed herein but is not to be construed as excluding other embodiments, but is capable of numerous other combinations, modifications and environments and is capable of modifications within the scope of the inventive concept, either as taught or as a matter of routine skill or knowledge in the relevant art. And that modifications and variations which do not depart from the spirit and scope of the invention are intended to be within the scope of the appended claims.

Claims (10)

1. An adaptive white balance method, comprising:
acquiring an image to be processed, wherein the image to be processed is in an RGB format;
counting pixel distribution histograms of all channels of the image to be processed;
calculating the proportion of pixel points with brightness values below a preset brightness threshold value in the image to be processed, and marking the proportion as a first proportion;
calculating the proportion of overlapping pixel points of the R, G, B channels in the image to be processed, and marking the proportion as a second proportion;
and determining a white balance algorithm according to the first proportion and the second proportion, and carrying out white balance correction on the image to be processed by utilizing the white balance algorithm.
2. The adaptive white balance method of claim 1, further comprising:
the image to be processed is downsampled before the pixel distribution histogram of each channel of the image to be processed is counted.
3. The method of claim 1, wherein determining a white balance algorithm based on the first and second ratios and using the white balance algorithm to correct the white balance of the image to be processed comprises:
if the first ratio is greater than the first threshold and the second ratio is greater than the second threshold, performing white balance correction on the image to be processed by adopting a truncation processing method, wherein a threshold value of the truncation processing adopts a first threshold value;
if the first proportion is larger than the first threshold value and the second proportion is smaller than or equal to the second threshold value, adopting a QCGP algorithm to carry out white balance correction on the image to be processed;
if the first ratio is less than or equal to the first threshold value and the second ratio is greater than the second threshold value, performing white balance correction on the image to be processed by adopting a mapping processing method, wherein a first threshold value is adopted as a threshold value of the mapping processing;
and if the first proportion is smaller than or equal to the first threshold value and the second proportion is smaller than or equal to the second threshold value, performing white balance correction on the image to be processed by adopting a histogram equalization/translation algorithm.
4. A method of adaptive white balance correction according to claim 3, wherein the white balance correction is performed on the image to be processed by using a truncation process, and wherein the truncation process has a threshold value of a first threshold value, including:
converting an image to be processed from RGB space to YC b C r Space, calculate C b Is a function of the mean and variance of (a), calculation C r Mean and variance of (C), where C b Representing red component information, C r Representing blue component information;
determining pixel points meeting preset rules in an image to be processed as initial white reference points, wherein the preset rules are as follows:
|C b -(M b +D b ×sign(M b ))|<r×D b
|C r -(r×M r +D r ×sign(M r ))|<r×D b
wherein M is b Is C b Mean value of M r Is C r Mean value of D b Is C b Variance of D r Is C r Is a variance of (2);
taking the point 5% -15% before the initial white reference point clock brightness value as the final white reference point;
calculating an average value of R, G, B three channel pixels of the final white reference point;
calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
gain R =Y max /R avgw
gain G =Y max /G avgw
gain B =Y max /B avgw
in the gain R For compensation coefficient of R channel, gain G For compensation factor of G channel, gain B For the compensation coefficient of B channel, R avgw Mean value of R channel, B avgw Mean of B channel, G avgw Mean of G channel, Y max Representing conversion of an image to be processed to YC b C r Maximum value of Y channel after channel;
according to the diagonal relation, the pixel value of each pixel point in the image to be processed is adjusted by using the compensation coefficient:
R′=Clip(gain R *R 0 )
G′=Clip(gain G *G 0 )
B′=Clip(gain B *B 0 )
in the formula, clip (. Cndot.) represents a truncated function, i.eR 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 Representing pixel point B in image to be processedThe original pixel value of the channel, R ' represents the final pixel value of the R channel of the pixel point in the image to be processed, G ' represents the final pixel value of the G channel of the pixel point in the image to be processed, and B ' represents the final pixel value of the B channel of the pixel point in the image to be processed.
5. A method according to claim 3, wherein the performing white balance correction on the image to be processed by using QCGP algorithm comprises:
calculating a maximum pixel value of an image to be processed and a first transformation coefficient, wherein the calculation formula of the first transformation coefficient is as follows:
K max =(R max +B max +G max )/3
wherein K is max R is the first transform coefficient max For the maximum pixel value of the image to be processed in the R channel, B max For the maximum pixel value of the image to be processed in the B channel, G max The maximum pixel value of the image to be processed in the G channel is obtained;
calculating an average pixel value of an image to be processed and a second transformation coefficient, wherein a calculation formula of the second transformation coefficient is as follows:
K avg =(R avg +B avg +G avg )/3
wherein K is avg For the second transform coefficient, R avg For the average pixel value of the image to be processed in the R channel, B avg For the average pixel value of the image to be processed in the B channel, G avg The average pixel value of the image to be processed in the G channel is obtained;
calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
u R R avg 2 +v R R avg =K avg
u R R max 2 +v R R max =K max
u G G avg 2 +v G G avg =K avg
u G G max 2 +v G G max =K max
u B B avg 2 +v B B avg =K avg
u B B max 2 +v B B max =K max
wherein u is R Representing the second order compensation coefficient of the R channel, v R Represents the first-order compensation coefficient of the R channel, u G Representing the second order compensation coefficient of the G channel, v G Represents the first order compensation coefficient of the G channel, u B Representing the second order compensation coefficient of the B channel, v B Representing a first-order compensation coefficient of the B channel;
according to the compensation coefficient, adjusting the pixel value of each pixel point in the image to be processed:
R =u R R 0 2 +v R R 0
G =u G G 0 2 +v G G 0
B =u B B 0 2 +v B B 0
wherein R is 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 Representing the original pixel value of a pixel point B channel in an image to be processed, R Representing the final pixel value, G, of the R channel of the pixel point in the image to be processed Representing final pixel value of pixel point G channel in image to be processed, B Representing the final pixel value of the pixel point B channel in the image to be processed.
6. A method of adaptive white balance correction according to claim 3, wherein the white balance correction is performed on the image to be processed by using a mapping process, and wherein the mapping process has a threshold value that is a first threshold value, and comprises:
converting an image to be processed from RGB space to YC b C r Space, calculate C b Mean and variance of (C) r Mean sum of (2)Variance of C b Representing red component information, C r Representing blue component information;
determining pixel points meeting preset rules in an image to be processed as initial white reference points, wherein the preset rules are as follows:
|C b -(M b +D b ×sign(M b ))|<r×D b
|C r -(r×M r +D r ×sign(M r ))|<r×D b
wherein M is b Is C b Mean value of M r Is C r Mean value of D b Is C b Variance of D r Is C r Is a variance of (2);
taking the point 5% -15% before the initial white reference point clock brightness value as the final white reference point;
calculating an average value of R, G, B three channel pixels of the final white reference point;
calculating compensation coefficients of all channels in the image to be processed, wherein the calculation formula of the compensation coefficients is as follows:
gain R =Y max /R avgw
gain G =Y max /G avgw
gain B =Y max /B avgw
in the gain R For compensation coefficient of R channel, gain G For compensation factor of G channel, gain B For the compensation coefficient of B channel, R avgw Mean value of R channel, B avgw Mean of B channel, G avgw Mean of G channel, Y max Representing conversion of an image to be processed to YC b C r Maximum value of Y channel after channel;
according to the diagonal relation, the pixel value of each pixel point in the image to be processed is adjusted by using the compensation coefficient:
R′=Scale(gain R *R 0 )
G′=Scale(gain G *G 0 )
B′=Scale(gain B *B 0 )
wherein Scale (·) represents the normalization function, i.eR 0 Representing the original pixel value, G, of a pixel R channel in an image to be processed 0 Representing the original pixel value of a pixel point G channel in an image to be processed, B 0 Representing the original pixel value of a pixel point B channel in the image to be processed, wherein R ' represents the final pixel value of a pixel point R channel in the image to be processed, G ' represents the final pixel value of a pixel point G channel in the image to be processed, B ' represents the final pixel value of a pixel point B channel in the image to be processed, X represents the pixel value of normalization processing, X min Representing the minimum value, X, of the normalized pixel max Representing the maximum value of the normalized pixel.
7. A method of adaptive white balance according to claim 3, wherein the white balance correction of the image to be processed using a histogram equalization/translation algorithm comprises:
respectively calculating the peak positions of histograms of three channels of the image R, G, B to be processed, and sequencing the three channels according to the sequence from small to large;
correcting smaller and larger color channels according to the peak value difference value:
R′=R 0 +g max -r max
B′=B 0 +g max -b max
wherein r is max G is the histogram peak position of R channel of the image to be processed max B for the histogram peak position of the G channel of the image to be processed max R is the position of the peak value of the histogram of the B channel of the image to be processed 0 Representing the original pixel value of a pixel point R channel in an image to be processed, B 0 The original pixel value of the pixel point B channel in the image to be processed is represented, R 'represents the final pixel value of the pixel point R channel in the image to be processed, and B' represents the final pixel value of the pixel point B channel in the image to be processed.
8. An adaptive white balance device, comprising:
the image acquisition module is used for acquiring an image to be processed, wherein the image to be processed is in an RGB format;
the histogram statistics module is used for counting pixel distribution histograms of all channels of the image to be processed;
the first calculation module is used for calculating the proportion of pixel points with brightness values below a preset brightness threshold value in the image to be processed, and marking the proportion as a first proportion;
the second calculation module is used for calculating the proportion of the overlapping pixel points of the R, G, B channels in the image to be processed, and marking the proportion as a second proportion;
and the white balance correction module is used for determining a white balance algorithm according to the first proportion and the second proportion and carrying out white balance correction on the image to be processed by utilizing the white balance algorithm.
9. An electronic device, comprising:
a memory storing execution instructions; and
a processor executing the execution instructions stored in the memory, causing the processor to perform the adaptive white balance method of any one of claims 1 to 7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein execution instructions, which when executed by a processor are adapted to implement the adaptive white balance method of any of claims 1 to 7.
CN202310574991.3A 2023-05-19 2023-05-19 Self-adaptive white balance method and device, electronic equipment and storage medium Pending CN116489330A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310574991.3A CN116489330A (en) 2023-05-19 2023-05-19 Self-adaptive white balance method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310574991.3A CN116489330A (en) 2023-05-19 2023-05-19 Self-adaptive white balance method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116489330A true CN116489330A (en) 2023-07-25

Family

ID=87225217

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310574991.3A Pending CN116489330A (en) 2023-05-19 2023-05-19 Self-adaptive white balance method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116489330A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117579813A (en) * 2024-01-16 2024-02-20 四川新视创伟超高清科技有限公司 Focal depth region imaging chip pose angle correction method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117579813A (en) * 2024-01-16 2024-02-20 四川新视创伟超高清科技有限公司 Focal depth region imaging chip pose angle correction method and system
CN117579813B (en) * 2024-01-16 2024-04-02 四川新视创伟超高清科技有限公司 Focal depth region imaging chip pose angle correction method and system

Similar Documents

Publication Publication Date Title
CN110046673B (en) No-reference tone mapping image quality evaluation method based on multi-feature fusion
US8035871B2 (en) Determining target luminance value of an image using predicted noise amount
EP0957629A2 (en) Processing of scanned negative films
CN109325922A (en) A kind of image self-adapting enhancement method, device and image processing equipment
CN112734650A (en) Virtual multi-exposure fusion based uneven illumination image enhancement method
WO2019061766A1 (en) Image processing method and device
WO2023103405A1 (en) Configuration method for compensation lookup table, compensation method for display panel, and configuration device for compensation lookup table
CN116489330A (en) Self-adaptive white balance method and device, electronic equipment and storage medium
CN111968065A (en) Self-adaptive enhancement method for image with uneven brightness
CN111462166A (en) Video image stabilization method and system based on histogram equalization optical flow method
Yu et al. Adaptive inverse hyperbolic tangent algorithm for dynamic contrast adjustment in displaying scenes
CN116188339A (en) Retinex and image fusion-based scotopic vision image enhancement method
CN109348207B (en) Color temperature adjusting method, image processing method and device, medium and electronic equipment
CN117156289A (en) Color style correction method, system, electronic device, storage medium and chip
WO2023284528A1 (en) Image enhancement method and apparatus, computer device, and storage medium
CN114266803A (en) Image processing method, image processing device, electronic equipment and storage medium
CN115293989A (en) Image enhancement method integrating MsRcR and automatic color gradation
Johnson Cares and concerns of CIE TC8-08: spatial appearance modeling and HDR rendering
WO2021223205A1 (en) Encoder, decoder, system, and method for determining tone mapping curve parameters
CN114445300A (en) Nonlinear underwater image gain algorithm for hyperbolic tangent deformation function transformation
CN114549358A (en) Low-illumination image enhancement method and system based on camera characteristics of guided filtering
CN113706400A (en) Image correction method, image correction device, microscope image correction method, and electronic apparatus
CN111738949A (en) Image brightness adjusting method and device, electronic equipment and storage medium
CN115118947B (en) Image processing method and device, electronic equipment and storage medium
Peicheng et al. Backlit image enhancement based on illumination-reflection imaging model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination