White balance adjustment method, computer readable storage medium and electronic device
By setting the colorless area covering the color temperature curve in image processing and setting the weight value for the statistical unit, the white balance jump problem is solved, and the stability and user experience of the video image are improved.
Patent Information
- Application Number
- CN202310107350.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-13
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2043-02-13
AI Technical Summary
The prior art can easily cause white balance jumps in image processing, especially in video applications. Due to noise and light source fluctuations, objects of a single color fall outside or within the white dot area in different frames, resulting in white balance correction. The coefficient fluctuates greatly, affecting the user experience.
By setting the colorless area covering the color temperature curve in the color coordinate system, and setting the weight value for each statistical unit, considering the relationship between the color coordinate points and the colorless area and the relationship between the coordinate value and the threshold, performing white balance adjustments to reduce The probability of white balance jump.
It effectively reduces the probability of white balance jump in the image, improves the stability and user experience of the video image, especially when shooting videos with a large number of backgrounds of the same color.
Smart Images

Figure CN116095292B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a white balance adjustment method, a computer-readable storage medium and an electronic device. Background Art
[0002] In digital image processing, white balance correction usually uses the color temperature curve method. For example, the grayscale card is photographed under light sources of different color temperatures, and the R / G and B / G values of the grayscale card image under each light source are calibrated. Then, a color temperature curve is fitted in the color coordinate system with R / G and B / G as the horizontal and vertical axes respectively. A white point area (or colorless area) is divided near the color temperature curve. When shooting an image, the R / G and B / G values of each pixel or each small area in the image are counted, and the pixels or small areas falling in the white point area are regarded as white points. The white balance correction coefficient is automatically calculated, and the white balance adjustment is performed. For example, the Chinese patent application with publication number CN101296384A.
[0003] The problem with the existing methods is that they easily cause white balance jumps. When an image contains a large area of a single-color object, such as a ceiling or wall, if its color is near the edge of the white point area, then the problem of white balance jumps is very likely to occur. The problem is particularly prominent in video applications. For example, when a camera is shooting, or a camera or mobile phone is recording a video, due to noise, light source fluctuations, etc., the single-color object may fall outside the white point area in some video frames, and fall within the white point area in some video frames. This causes the white balance correction coefficients calculated for different frames to fluctuate greatly, causing the white balance of the video image to jump. Severe white balance jumps will affect the user experience. Summary of the invention
[0004] The problem solved by the present invention is that the prior art easily causes white balance jump.
[0005] To solve the above problems, the present invention provides a white balance adjustment method, comprising: establishing a color coordinate system with R / G and B / G as axes; marking the color coordinates of white target objects or gray target objects images taken under light sources of different color temperatures as white points in the color coordinate system; fitting a color temperature curve based on the white points; setting a colorless area in the color coordinate system, the colorless area covers part or all of the color temperature curve, and the number of white points in the colorless area is greater than the number of white points outside the colorless area; dividing an original image into non-overlapping statistical units, and establishing a color coordinate point corresponding to each statistical unit in the color coordinate system; setting a weight value for the color coordinate point according to the relationship between the color coordinate point and the colorless area, and the relationship between the coordinate value of the color coordinate point and the coordinate value threshold; and performing white balance adjustment on the original image according to the weight value corresponding to the color coordinate point.
[0006] Optionally, the color coordinate point includes: a first color coordinate point; the first color coordinate point is located outside the colorless area, and the coordinate value of the first color coordinate point does not exceed the coordinate value threshold, and the first weight value set for the first color coordinate point is related to the first distance between the first color coordinate point and the colorless area.
[0007] Optionally, the first weight value is between 0 and 1, and decreases as the first distance increases.
[0008] Optionally, the first weight value changes with the first distance in a linear or Gaussian function.
[0009] Optionally, the first weight value is set by performing linear interpolation on a mapping relationship, where the mapping relationship is a corresponding relationship between a preset first distance and a first weight value.
[0010] Optionally, the correspondence between the first distance and the first weight value in the mapping relationship is obtained by sampling in a Gaussian function.
[0011] Optionally, the boundary line of the colorless area includes: a first boundary line and a second boundary line, the first boundary line and the second boundary line are respectively located on both sides of the color temperature curve; a right triangle with the first color coordinate point as the right-angle vertex is established in the color coordinate system, the two right-angled sides of the right triangle are respectively parallel to the horizontal axis and the vertical axis, and the two acute-angled vertices of the right triangle are located on the first boundary line or the second boundary line close to the first color coordinate point; the calculation formula of the first distance h is:
[0012]
[0013] In the right triangle, Δx is the length of the right angle side parallel to the horizontal axis, and Δy is the length of the right angle side parallel to the vertical axis.
[0014] Optionally, the boundary line of the colorless area includes: a first boundary line and a second boundary line, the first boundary line and the second boundary line are respectively located on both sides of the color temperature curve; a right triangle with the first color coordinate point as the right-angle vertex is established in the color coordinate system, the two right-angled sides of the right triangle are respectively parallel to the horizontal axis and the vertical axis, and the two acute-angled vertices of the right triangle are located on the first boundary line or the second boundary line close to the first color coordinate point; the calculation formula of the first distance h is:
[0015]
[0016] In the right triangle, Δx is the length of the right angle side parallel to the horizontal axis, and Δy is the length of the right angle side parallel to the vertical axis.
[0017] Optionally, the color coordinate point includes: a second color coordinate point; the second color coordinate point is located within the colorless area, and the coordinate value of the second color coordinate point does not exceed the coordinate value threshold, and the second weight value set for the second color coordinate point is 1.
[0018] Optionally, the color coordinate point includes: a third color coordinate point; a coordinate value of the third color coordinate point exceeds the coordinate value threshold, and a third weight value set for the third color coordinate point is 0.
[0019] Optionally, the step of performing white balance adjustment on the original image according to the weight value corresponding to the color coordinate point includes: determining a first coefficient coef g2r and the second coefficient coef g2b ; Multiply all R pixels in the original image by the first coefficient coef g2r , all B pixels are multiplied by the second coefficient coef g2b , all G pixels remain unchanged; wherein the first coefficient coef g2r and the second coefficient coef g2b The calculation formula is:
[0020]
[0021] N is the number of statistical units, mG i is the average value of G pixels in the i-th statistical unit, mR i is the average value of R pixels in the ith statistical unit, mB i is the average value of B pixels in the i-th statistical unit, weight i is the weight value corresponding to the i-th statistical unit.
[0022] The present invention also provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the steps of the above method.
[0023] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes the steps of the method described in the claim when running the computer program.
[0024] Compared with the prior art, the technical solution of the present invention has the following advantages:
[0025] By using the technical solution of the present invention to set weight values for color coordinate points, not only the relationship between the color coordinate point and the colorless area is considered, but also the relationship between the coordinate value of the color coordinate point and the coordinate value threshold is considered. When shooting a video containing a large number of backgrounds with the same color, the probability of white balance jumps in the image can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 is a flowchart of a white balance adjustment method according to an embodiment of the present invention;
[0027] Figure 2 is a schematic diagram of a white point and a color temperature curve according to an embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of the boundary and the colorless area of an embodiment of the present invention;
[0029] Figure 4 is another schematic diagram of the boundary and the colorless area of an embodiment of the present invention;
[0030] Figure 5 is a schematic diagram of Bayer domain image division according to an embodiment of the present invention;
[0031] Figure 6 is another schematic diagram of the boundary and the colorless area of an embodiment of the present invention;
[0032] Figure 7 is a schematic diagram of the relationship between the first weight value and the first distance in an embodiment of the present invention;
[0033] Figure 8 is another schematic diagram of the relationship between the first weight value and the first distance in an embodiment of the present invention;
[0034] Fig. 9 is another schematic diagram of the relationship between the first weight value and the first distance in an embodiment of the present invention;
[0035] Fig.10 is a schematic diagram of a first distance calculation in an embodiment of the present invention;
[0036] Fig.11 is a schematic diagram of the relationship between the first weight value and the square of the first distance in an embodiment of the present invention;
[0037] Fig.12 It is a schematic diagram of the scene with a single color;
[0038] Fig.13 is the first coefficient calculated using the prior art;
[0039] Fig.14 is the second coefficient calculated using the prior art;
[0040] Fig.15 is a first coefficient calculated using an embodiment of the present invention;
[0041] Fig.16 is the second coefficient calculated using the embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0043] like Figure 1 As shown, an embodiment of the present invention provides a white balance adjustment method, comprising:
[0044] Step S1, establishing a color coordinate system with R / G and B / G as axes;
[0045] Step S2, marking the color coordinates of the white target or gray target image taken under light sources of different color temperatures as white points in the color coordinate system;
[0046] Step S3, fitting a color temperature curve based on the white point;
[0047] Step S4, setting a colorless area in the color coordinate system, wherein the colorless area covers part or all of the color temperature curve, and the number of white points in the colorless area is greater than the number of white points outside the colorless area;
[0048] Step S5, dividing the original image into non-overlapping statistical units, and establishing a color coordinate point corresponding to each statistical unit in the color coordinate system;
[0049] Step S6, setting a weight value for the color coordinate point according to the relationship between the color coordinate point and the colorless area, and the relationship between the coordinate value of the color coordinate point and the coordinate value threshold;
[0050] Step S7, adjusting the white balance of the original image according to the weight values corresponding to the color coordinate points.
[0051] By using this embodiment to set weight values for color coordinate points, not only the relationship between the color coordinate point and the colorless area is considered, but also the relationship between the coordinate value of the color coordinate point and the coordinate value threshold is considered. When shooting a video containing a large number of backgrounds with the same color, the probability of white balance jumps in the image can be reduced.
[0052] Steps S1 to S3 can be implemented using existing technologies. Specifically, the white target and the gray target can be a grayscale card, or a gray block and a white block in a color card. Taking the grayscale card as an example, since the grayscale card has no color, the B / G and R / G of the captured grayscale card are the coordinates of the white point. Figure 2 As shown in the figure, 8 white dots of different shapes correspond to 8 light sources with different color temperatures, and 4 white dots of the same shape correspond to 4 gray blocks or white blocks with different grayscales. Take a picture of the grayscale card under light sources with different color temperatures, and mark the obtained white points in the color coordinate system with R / G and B / G as the horizontal and vertical axes. Based on these white points, a color temperature curve (dashed line in the figure) can be fitted.
[0053] Execute step S4, such as Figure 3 As shown, a colorless area is set in the color coordinate system. The colorless area can be: a closed area surrounded by the first boundary line LUT1, the second boundary line LUT2, boundary 2 and boundary 3. The first boundary line LUT1 and the second boundary line LUT2 are located on both sides of the color temperature curve, which can be obtained by translating and sampling the color temperature curve; the coordinates of the LUT curve can also be set and adjusted by yourself to achieve a more accurate white balance effect.
[0054] Figure 3 Boundary 1, Boundary 2, Boundary 3, and Boundary 4 in the figure actually represent the coordinate value thresholds. Boundary 2 and Boundary 3 represent the horizontal coordinate range in the coordinate value threshold, limiting the horizontal range. Boundary 1 and Boundary 4 represent the vertical coordinate range in the coordinate value threshold, limiting the vertical range.
[0055] In this embodiment, the colorless area is taken as an example as a closed area surrounded by the first boundary line LUT1, the second boundary line LUT2, the boundary 2 and the boundary 3. In other cases, it can also be a closed area surrounded by the first boundary line LUT1, the second boundary line LUT2, the boundary 1, the boundary 2, the boundary 3 and the boundary 4. Figure 4 shown.
[0056] When setting the colorless area, you can first measure the white point, fit the color temperature curve, and try to expand the area near the color temperature curve. Figure 2 or Figure 3 The colorless area shown. Then, shoot a 24-color color checker under light sources of various color temperatures, and fine-tune the colorless area so that under light sources of various color temperatures, as many white points as possible corresponding to the gray blocks and white blocks in the color checker fall within the colorless area, and the number of white points in the colorless area is greater than the number of white points outside the colorless area. The color coordinates corresponding to other color blocks (colored) fall outside the colorless area as much as possible, so as to determine the colorless area. The colorless area is not uniquely determined, and the range of the colorless area obtained by debuggers with different experiences and preferences may be slightly different. But the general idea is that the colorless area should contain as many gray blocks and white blocks as possible on the color checker under various light sources, and as few color blocks as possible.
[0057] After the colorless area is set, step S5 is executed. Figure 5 As shown, taking the Bayer domain image as an example: In the Bayer domain, an image is divided into N non-overlapping statistical units u i , i = 1, ..., N. The minimum repeating unit of the Bayer domain is 4 pixels: RGGB. Each statistical unit includes several consecutive minimum repeating units, such as 1, 2 or 4 minimum repeating units. In this example, each statistical unit contains 4 minimum repeating units.
[0058] It is understandable that the statistical unit can also use an RGB domain image. The RGB domain refers to an image with three complete color channels of R, G, and B obtained after demosaicing the Bayer domain image. Similar to the Bayer domain image, the RGB domain image can be divided into non-overlapping statistical units. For example, a square area of 4x4 pixels is used as a statistical unit to calculate the R / G and B / G values. Of course, a single pixel can also be used for calculation, in which case the size of the statistical unit is equivalent to 1x1.
[0059] After the statistical unit is divided, the color coordinates of each statistical unit are calculated, and the corresponding color coordinate points are established in the color coordinate system. When a statistical unit contains multiple R pixels, multiple G pixels, or multiple B pixels: Assuming that the average value of all R pixels is mRi, the average value of all G pixels is mGi, and the average value of all B pixels is mBi, then the horizontal coordinate of the color coordinate point corresponding to the statistical unit is R / G = mRi / mGi, and the vertical coordinate is B / G = mBi / mGi.
[0060] After determining the color coordinate point corresponding to each statistical unit, step S6 is executed to set a weight value for each color coordinate point. Different from the prior art, when setting the weight value, this embodiment not only considers the relationship between the color coordinate point and the colorless area, but also considers the relationship between the coordinate value of the color coordinate point and the coordinate value threshold. After obtaining the weight value corresponding to each statistical unit, step S7 is executed to adjust the white balance of the original image.
[0061] In step S6, according to the relationship between the color coordinate point and the colorless area and the coordinate value threshold, the color coordinate point can be divided into: a first color coordinate point, a second color coordinate point and a third color coordinate point.
[0062] Among them, the color coordinate point located outside the colorless area and whose coordinate value does not exceed the coordinate value threshold is the first color coordinate point; the color coordinate point located within the colorless area and whose coordinate value does not exceed the coordinate value threshold is the second color coordinate point; and the color coordinate point whose coordinate value exceeds the coordinate value threshold is the third color coordinate point.
[0063] The second color coordinate point in the colorless area adjacent to the color temperature curve and whose coordinate value does not exceed the coordinate value threshold has the highest probability of being a white object, so the second weight value set for the second color coordinate point is 1, which ensures that a large number of true white points have the highest weight value.
[0064] The probability that the third color coordinate point that exceeds the coordinate value threshold range is a white point is very low, so the third weight value set for the third color coordinate point is 0.
[0065] For a first color coordinate point that is adjacent to the color temperature curve and has a coordinate value that does not exceed the coordinate value threshold but is outside the colorless area, the first weight value set for the first color coordinate point in this embodiment is related to the first distance between the colorless areas.
[0066] The present embodiment does not directly reduce the weight values of color coordinate points outside the colorless area to 0 because: when there is no colored object in the shooting scene, theoretically most of the pixels counted should be located in the colorless area near the color temperature curve. However, the inventors have found that sometimes most of the pixels are located near the edge of the colorless area. Figure 6 As shown; the inventors further discovered that since the CIE standard light source is used to measure the color temperature curve, and the lighting sources used in actual life have different standards, some do not meet the CIE standard, resulting in color deviation, causing the photographed white objects to not be completely located in the colorless area in the color plane, but mostly concentrated on the edge of the colorless area.
[0067] Based on the above research conclusions, this embodiment proposes: the first weight value set for the first color coordinate point is related to the first distance between the first color coordinate point and the colorless area. Specifically, the first weight value is set between 0 and 1, and decreases as the first distance increases. The slower the first weight decreases, the less likely the white balance jump will occur, but the accuracy of the white balance will decrease; the faster the first weight decreases, the more likely the white balance jump will occur, so it can be selected according to actual needs. When shooting a video containing a large number of backgrounds of the same color, using the method described in this embodiment can significantly reduce the probability of white balance jumps in the image.
[0068] like Figure 7 As shown, the first weight value W can decrease linearly from 1 to 0 with the first distance h:
[0069]
[0070] Among them, h th is the distance threshold, which is determined based on experimental results or experience. th When , the first weight value W = 0. This calculation method of the first weight value has a small amount of calculation, but the model is not fine enough, the adjustable parameters are few, and the flexibility is not high when debugging the equipment.
[0071] Optionally, the first weight value W decays with the first distance h in a Gaussian function, such as Figure 8 As shown:
[0072]
[0073] Among them, σ is a parameter that controls the decay speed of the first weight value W. The larger σ is, the slower the first weight value W decays; the smaller σ is, the faster the first weight value W decays; σ can be determined based on experimental results or experience. When the first distance h = 0, the first weight value W = 1. This calculation method is more accurate, but the amount of calculation is large, it consumes more hardware resources, and there are fewer adjustable parameters, so the flexibility is not high when debugging the device.
[0074] Considering the advantages and disadvantages of the above two methods, this embodiment proposes that: the first weight value W is set by linear interpolation of the mapping relationship. The mapping relationship is the corresponding relationship between the preset first distance h and the first weight value W.
[0075] like Fig. 9 As shown, according to the mapping relationship specified by the LUT, the first distance h is mapped to the first weight value W. Specifically, several groups of mapping relationships from the first distance h to the first weight value W are specified in the LUT, as shown in Table 1 below.
[0076] Table 1
[0077] Serial number 1 2 3 4 5 6 h 0 0.01 0.02 0.03 0.04 0.05 W 1 0.95 0.7 0.25 0.08 0
[0078] The correspondence between the first distance h and the first weight value W in the mapping relationship can be obtained by sampling in the Gaussian function. The first weight value W corresponding to any first distance h can be obtained by linear interpolation of Table 1. This method has a small amount of calculation, saves hardware resources, and is suitable for applications with high requirements on resources, power consumption, and real-time performance. In addition, this LUT method has many adjustable parameters, and can be effectively debugged for shooting devices with different characteristics to obtain better white balance effects. Experiments have found that a LUT consisting of 6 groups of parameters can achieve better results.
[0079] In order to obtain the first weight value W, it is necessary to first calculate the first distance h, such as Fig.10 As shown, the calculation method of the first distance h is as follows:
[0080] In the color coordinate system, a first color coordinate point p is created. i The right triangle has two right-angled sides parallel to the horizontal axis R / G and the vertical axis B / G respectively, and the two acute-angled vertices of the right triangle are located near the first color coordinate point p i On the second boundary line LUT2.
[0081] The calculation formula of the first distance h is:
[0082]
[0083] In the right triangle, Δx is the length of the right-angled side parallel to the horizontal axis R / G, Δy is the length of the right-angled side parallel to the vertical axis B / G, and Δd is the length of the hypotenuse.
[0084] If the distance from a point to a curve is strictly calculated according to the geometric method, it is necessary to find the derivative of the curve, calculate the tangent and the distance from the point to the tangent, which is computationally intensive and not suitable for handheld devices with high real-time requirements. Therefore, in this embodiment, it is assumed that the first distance h is perpendicular to the hypotenuse of the right triangle, and the distance from the right vertex to the hypotenuse is used to represent the first color coordinate point p i Although the first distance h calculated in this way is slightly different from the actual distance from the first color coordinate point pi to the second boundary line LUT2, the calculation amount is small, the accuracy is sufficient, and real-time calculation can be achieved, which is suitable for applications with high requirements for white balance real-time performance, such as the camera function of a mobile phone.
[0085] Considering that formula 1 needs to calculate the square root, it still requires a certain amount of calculation, so it can be further simplified to formula 2:
[0086]
[0087] Combination Fig.11 The first weight W and h 2 The relationship curve of can be used to implement this solution without calculating the square root, further saving computing resources.
[0088] After the weight value corresponding to the color coordinate point is determined, step S7 is executed to perform white balance adjustment on the original image.
[0089] First, determine the first coefficient coef for white balance adjustment g2r and the second coefficient coef g2b Then, all R pixels in the original image are multiplied by the first coefficient coef g2r , all B pixels are multiplied by the second coefficient coef g2b , all G pixels remain unchanged.
[0090] Among them, the first coefficient coef g2r and the second coefficient coef g2b The calculation formula is:
[0091]
[0092] In formula 3, N is the total number of statistical units, mG i is the average value of G pixels in the i-th statistical unit, mR i is the average value of R pixels in the ith statistical unit, mB i is the average value of B pixels in the i-th statistical unit, weighti is the weight value corresponding to the ith statistical unit. The weight value corresponding to the ith statistical unit may be the first weight value, the second weight value or the third weight value.
[0093] Since the weights set for points outside the colorless area in this embodiment gradually decrease, when the scene contains a large number of backgrounds of the same color, the video image is less likely to have white balance jump problems, and the amount of calculation is small, making it easy to achieve real-time output on a handheld device.
[0094] like Fig.12 As shown in the figure, the same RGB image sensor as in the above example is used to continuously capture 100 frames of images of a white ceiling, and the light source is a white LED light with a color temperature of 5665K. Since the same image sensor is used, the color temperature curve characteristics and the colorless area are the same as those in the above example. Figure 3 Same as below Figure 6 shown.
[0095] When calculating the white balance adjustment coefficient in the prior art, the weight value corresponding to the color coordinate point within the colorless area is set to 1, and the weight value corresponding to the color coordinate point outside the colorless area is set to 0. Using the prior art to process the 100 frames of images collected, we can get Fig.13 The first coefficient coef g2r and Fig.14 The second coefficient coef shown g2b Change graph.
[0096] Since most pixels are concentrated at the edge of the colorless area, they are easily affected by noise disturbance or light source fluctuation, which can easily cause a large jump in the number of pixels in the colorless area between frames. The periodicity of alternating current makes light source fluctuations very common, especially for LED light sources. Indoor light is usually insufficient for the image sensor of a digital camera, so video image noise disturbances are also very common. Therefore, when shooting similar Fig.12 In such a scene with a single color, the white balance adjustment coefficient calculated by the prior art fluctuates greatly, such as 13 and Fig.14 As shown, the automatic white balance between video frames is prone to jump, affecting the user experience.
[0097] The technical solution of this embodiment does not simply adopt the binary setting method of 0 and 1, but continuously adjusts the weight according to the distance between the color coordinate point of the statistical unit and the colorless area. Therefore, the calculated first coefficient coef g2r and the second coefficient coef g2b Very stable between frames, such as Fig.15 and Fig.16 As shown, the white balance jump is obviously avoided.
[0098] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. A white balance adjustment method, It is characterized in that include: Establish a color coordinate system with R / G and B / G as axes; Marking the color coordinates of the white target or gray target image captured under light sources of different color temperatures as white points in the color coordinate system; Fitting a color temperature curve based on the white point; A colorless area is set in the color coordinate system, the colorless area covers part or all of the color temperature curve, and the number of white points in the colorless area is greater than the number of white points outside the colorless area; Divide the original image into non-overlapping statistical units, and establish a color coordinate point corresponding to each statistical unit in the color coordinate system; A weight value is set for the color coordinate point according to the relationship between the color coordinate point and the colorless area, and the relationship between the coordinate value of the color coordinate point and the coordinate value threshold; the coordinate value threshold includes: two horizontal coordinate thresholds and two vertical coordinate thresholds; boundaries 1 and 4 are straight lines parallel to the R / G axis where the two vertical coordinate thresholds are located, and boundaries 2 and 3 are straight lines parallel to the B / G axis where the two horizontal coordinate thresholds are located; Performing white balance adjustment on the original image according to the weight values corresponding to the color coordinate points; The colorless area is a closed area surrounded by the boundaries 1, 2, 3 and 4, the first boundary line and the second boundary line, and the color coordinate points include: a first color coordinate point, a second color coordinate point and a third color coordinate point; the first color coordinate point is located outside the colorless area, and the first color coordinate point does not exceed the range surrounded by the boundaries 1, 2, 3 and 4; the second color coordinate point is located within the colorless area, and the second color coordinate point does not exceed the range surrounded by the boundaries 1, 2, 3 and 4; the third color coordinate point exceeds the range surrounded by the boundaries 1, 2, 3 and 4; the first boundary line and the second boundary line are respectively located on both sides of the color temperature curve; A first weight value set for the first color coordinate point is related to a first distance between the first color coordinate point and the colorless area, the first weight value is between 0 and 1, and decreases as the first distance increases; The second weight value set for the second color coordinate point is 1; The third weight value set for the third color coordinate point is 0.
2. The white balance adjustment method according to claim 1, It is characterized in that The first weight value changes with the first distance in a linear or Gaussian manner.
3. The white balance adjustment method according to claim 1, It is characterized in that The first weight value is set by performing linear interpolation on the mapping relationship, where the mapping relationship is a corresponding relationship between a preset first distance and a first weight value.
4. The white balance adjustment method according to claim 3, It is characterized in that The corresponding relationship between the first distance and the first weight value in the mapping relationship is obtained by sampling in a Gaussian function.
5. The white balance adjustment method according to any one of claims 2 to 4, It is characterized in that Establishing a right triangle with the first color coordinate point as a right-angled vertex in the color coordinate system, wherein two right-angled sides of the right triangle are parallel to the horizontal axis and the vertical axis respectively, and two acute-angled vertices of the right triangle are located on a first boundary line or a second boundary line close to the first color coordinate point; The calculation formula of the first distance h is: ; Among them, in the right triangle, is the length of the right angle side parallel to the horizontal axis, is the length of the right angle side parallel to the longitudinal axis.
6. The white balance adjustment method according to claim 1, It is characterized in that The step of adjusting the white balance of the original image according to the weight value corresponding to the color coordinate point comprises: Determine the first coefficient of white balance adjustment and the second coefficient ; Multiply all R pixels in the original image by the first coefficient , all B pixels are multiplied by the second coefficient , all G pixels remain unchanged; Among them, the first coefficient and the second coefficient The calculation formula is: ; N is the number of statistical units, mG i is the average value of G pixels in the i-th statistical unit, mR i is the average value of R pixels in the ith statistical unit, mB i is the average value of B pixels in the i-th statistical unit, weight i is the weight value corresponding to the i-th statistical unit.
7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that The computer program is executed by a processor to implement the steps of the method according to any one of claims 1 to 6.
8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, It is characterized in that When the processor runs the computer program, the steps of the method according to any one of claims 1 to 6 are performed.
Citation Information
Patent Citations
White balance adjusting device, imaging apparatus, and recording medium storing white balance adjusting program
CN101296384A
White balance processing method and device, terminal device and memory medium
CN108377372A
White balance adjusting method and device
CN115190283A
Image white balance processing method and electronic equipment
CN115334295A
White balance method based on blue sky discrimination, electronic equipment and storage medium
CN116828324A
