White balance compensation method and device, electronic equipment and storage medium

The pre-flash compensation function is used to compensate for the white balance parameters of the flash during pre-flash, solving the problem of poor white balance accuracy of the flash under different ambient light conditions, achieving more accurate white balance processing, and improving the shooting effect.

CN120825637APending Publication Date: 2025-10-21BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410451332.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-15
Publication Date
2025-10-21

AI Technical Summary

Technical Problem

The flash has poor white balance accuracy under different ambient light conditions, resulting in color cast problems when shooting.

Method used

The pre-flash compensation function is used to compensate the white balance parameters of the flash during pre-flash to obtain a more accurate third white balance parameter, thereby reducing the white balance difference between the flash pre-flash and the main flash.

Benefits of technology

It improves the accuracy of flash white balance, avoids color cast problems during shooting, and improves shooting effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120825637A_ABST
    Figure CN120825637A_ABST
Patent Text Reader

Abstract

The invention relates to a white balance compensation method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring a first white balance parameter during shooting under current ambient light, wherein the first white balance parameter is determined based on a white balance parameter when main flash shooting of a flash lamp is turned on and a white balance parameter when the flash lamp is turned off; acquiring a second white balance parameter during shooting under the current ambient light, wherein the second white balance parameter is a white balance parameter when a flash lamp is turned on for pre-flash shooting; compensating the second white balance parameter based on a pre-flashing compensation function to obtain a third white balance parameter, the pre-flashing compensation function being obtained by fitting white balance parameters obtained during shooting under different ambient lights; and determining a target white balance parameter based on the first white balance parameter and the third white balance parameter, the target white balance parameter being used for performing white balance processing on the to-be-processed image. The method improves the accuracy of white balance of the flash lamp, and avoids the problem of color cast during shooting of the flash lamp.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to a white balance compensation method, device, electronic device, and storage medium. Background Art

[0002] The flash is an essential feature of mobile phones. Using it to illuminate the surroundings in low-light conditions, compensate for light deficiencies, and thus improve image brightness, enhancing the phone's low-light photography capabilities. When shooting in low-light conditions, the flash typically fires a pre-flash to focus light, followed by a main flash at a fixed intensity and brightness to provide fill light.

[0003] The brightness and color temperature of the flash do not change according to the intensity of the ambient light and the changes in color temperature. As a result, when the shooting distance changes or in an environment with warm or cold color temperature (higher or lower color temperature), the flash white balance is affected by the color temperature of the ambient light and the shooting distance, and the accuracy is poor, resulting in color cast problems when shooting with flash. Summary of the Invention

[0004] To overcome the problems existing in the related art, the present disclosure provides a white balance compensation method, device, electronic device and storage medium.

[0005] According to a first aspect of an embodiment of the present disclosure, a white balance compensation method is provided, the method comprising:

[0006] Obtaining a first white balance parameter when shooting under the current ambient light, where the first white balance parameter is determined based on a white balance parameter when shooting with the flash on and a white balance parameter when shooting with the flash off;

[0007] Acquire a second white balance parameter when shooting under the current ambient light, where the second white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on;

[0008] Compensating the second white balance parameter based on a pre-flash compensation function to obtain a third white balance parameter, wherein the pre-flash compensation function is obtained by fitting the white balance parameters obtained when shooting under different ambient light conditions;

[0009] A target white balance parameter is determined based on the first white balance parameter and the third white balance parameter, and the target white balance parameter is used to perform white balance processing on the image to be processed.

[0010] In some embodiments, obtaining a first white balance parameter when shooting under the current ambient light includes:

[0011] Obtaining a pre-stored fourth white balance parameter, wherein the fourth white balance parameter is a white balance parameter when the flash is turned on for main flash shooting;

[0012] Obtaining first log information when shooting with the flash turned off under the current ambient light;

[0013] Obtaining a fifth white balance parameter from the first log information;

[0014] The first white balance parameter is determined based on the fourth white balance parameter and the fifth white balance parameter.

[0015] In some embodiments, the method further comprises:

[0016] The first image is captured in total darkness with the flash firing.

[0017] determining a first ratio and a second ratio based on pixel parameters of pixel points in the target area in the first image; wherein the pixel parameters include a first channel parameter, a second channel parameter, and a third channel parameter, the first ratio is a ratio between the first channel parameter and the second channel parameter, and the second ratio is a ratio between the third channel parameter and the second channel parameter;

[0018] The first ratio and the second ratio are determined as the fourth white balance parameter.

[0019] In some embodiments, determining the first white balance parameter based on the fourth white balance parameter and the fifth white balance parameter includes:

[0020] Determining, based on the ambient light brightness of the current ambient light, a flash sensitivity parameter corresponding to the ambient light brightness;

[0021] Based on the flash sensitivity parameter, a weighted sum is performed on the fourth white balance parameter and the fifth white balance parameter to obtain the first white balance parameter.

[0022] In some embodiments, obtaining the second white balance parameter when shooting under the current ambient light includes:

[0023] Obtaining a pre-stored sixth white balance parameter, wherein the sixth white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on in a completely dark environment;

[0024] determining the second white balance parameter based on the sixth white balance parameter, the ambient light brightness of the current ambient light, and pre-flash valid statistical data points;

[0025] Among them, the pre-flash effective statistical data points include data points located in a preset gray area in the coordinate system, and the data points in the coordinate system are determined based on the pixel parameters of the pixel points when the flash pre-flash is turned on under the current ambient light. The horizontal coordinate of the coordinate system is the ratio between the first channel parameter and the second channel parameter in the pixel parameters, and the vertical coordinate of the coordinate system is the ratio between the third channel parameter and the second channel parameter in the pixel parameters.

[0026] In some embodiments, the method further comprises:

[0027] Get the second log information when shooting with the flash pre-flash in complete darkness;

[0028] Acquire a sixth white balance parameter from the second log information.

[0029] In some embodiments, the white balance parameter includes a first ratio and a second ratio, wherein the first ratio is a ratio between a first channel parameter and a second channel parameter in the pixel parameters, and the second ratio is a ratio between a third channel parameter and the second channel parameter in the pixel parameters;

[0030] The compensating the second white balance parameter based on the pre-flash compensation function to obtain the third white balance parameter includes:

[0031] using the first ratio of the second white balance parameter as an input of the pre-flash compensation function to obtain a second ratio output by the pre-flash compensation function;

[0032] The first ratio of the second white balance parameter and the second ratio output by the pre-flash compensation function are determined as the third white balance parameter.

[0033] In some embodiments, the method further comprises:

[0034] Obtaining first and second white balance parameters when shooting under different ambient light conditions;

[0035] The first white balance parameter and the second white balance parameter when shooting under the different ambient light conditions are fitted to obtain the pre-flash compensation function, where the pre-flash compensation function is a cubic polynomial function.

[0036] In some embodiments, determining a target white balance parameter based on the first white balance parameter and the third white balance parameter includes:

[0037] Determining, based on the ambient light brightness of the current ambient light, a flash sensitivity parameter corresponding to the ambient light brightness;

[0038] Based on the flash sensitivity parameter, a weighted sum is performed on the first white balance parameter and the third white balance parameter to obtain the target white balance parameter.

[0039] According to a second aspect of an embodiment of the present disclosure, a white balance compensation device is provided, the device comprising:

[0040] A first parameter acquisition module is configured to acquire a first white balance parameter when shooting under current ambient light, where the first white balance parameter is determined based on a white balance parameter when shooting with the flash on and a white balance parameter when shooting with the flash off;

[0041] A second parameter acquisition module is configured to acquire a second white balance parameter when shooting under the current ambient light, wherein the second white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on;

[0042] a white balance compensation module configured to compensate the second white balance parameter based on a pre-flash compensation function to obtain a third white balance parameter, wherein the pre-flash compensation function is obtained by fitting the white balance parameters obtained when shooting under different ambient light conditions;

[0043] The parameter determination module is configured to determine a target white balance parameter based on the first white balance parameter and the third white balance parameter, where the target white balance parameter is used to perform white balance processing on the image to be processed.

[0044] In some embodiments, the first parameter acquisition module is configured to:

[0045] Obtaining a pre-stored fourth white balance parameter, wherein the fourth white balance parameter is a white balance parameter when the flash is turned on for main flash shooting;

[0046] Obtaining first log information when shooting with the flash turned off under the current ambient light;

[0047] Obtaining a fifth white balance parameter from the first log information;

[0048] The first white balance parameter is determined based on the fourth white balance parameter and the fifth white balance parameter.

[0049] In some embodiments, the apparatus further comprises:

[0050] An image capture module is configured to capture a first image when the flash is turned on for main flash in a completely dark environment;

[0051] a ratio determination module configured to determine a first ratio and a second ratio based on pixel parameters of pixel points in the target area in the first image; wherein the pixel parameters include a first channel parameter, a second channel parameter, and a third channel parameter, the first ratio is a ratio between the first channel parameter and the second channel parameter, and the second ratio is a ratio between the third channel parameter and the second channel parameter;

[0052] The third parameter acquisition module is further configured to determine the first ratio and the second ratio as the fourth white balance parameter.

[0053] In some embodiments, the first parameter acquisition module is configured to:

[0054] Determining, based on the ambient light brightness of the current ambient light, a flash sensitivity parameter corresponding to the ambient light brightness;

[0055] Based on the flash sensitivity parameter, a weighted sum is performed on the fourth white balance parameter and the fifth white balance parameter to obtain the first white balance parameter.

[0056] In some embodiments, the second parameter acquisition module is configured to:

[0057] Obtaining a pre-stored sixth white balance parameter, wherein the sixth white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on in a completely dark environment;

[0058] determining the second white balance parameter based on the sixth white balance parameter, the ambient light brightness of the current ambient light, and pre-flash valid statistical data points;

[0059] Among them, the pre-flash effective statistical data points include data points located in a preset gray area in the coordinate system, and the data points in the coordinate system are determined based on the pixel parameters of the pixel points when the flash pre-flash is turned on under the current ambient light. The horizontal coordinate of the coordinate system is the ratio between the first channel parameter and the second channel parameter in the pixel parameters, and the vertical coordinate of the coordinate system is the ratio between the third channel parameter and the second channel parameter in the pixel parameters.

[0060] In some embodiments, the apparatus further comprises:

[0061] a log acquisition module configured to acquire second log information when a flash pre-flash is turned on to shoot in a completely dark environment;

[0062] The fourth parameter acquisition module is configured to acquire a sixth white balance parameter from the second log information.

[0063] In some embodiments, the white balance parameter includes a first ratio and a second ratio, wherein the first ratio is a ratio between a first channel parameter and a second channel parameter in the pixel parameters, and the second ratio is a ratio between a third channel parameter and the second channel parameter in the pixel parameters;

[0064] The white balance compensation module is configured to:

[0065] using the first ratio of the second white balance parameter as an input of the pre-flash compensation function to obtain a second ratio output by the pre-flash compensation function;

[0066] The first ratio of the second white balance parameter and the second ratio output by the pre-flash compensation function are determined as the third white balance parameter.

[0067] In some embodiments, the apparatus further comprises:

[0068] a fifth parameter acquisition module, configured to acquire a first white balance parameter and a second white balance parameter when shooting under different ambient light conditions;

[0069] The compensation function determination module is configured to fit the first white balance parameter and the second white balance parameter when shooting under different ambient light conditions to obtain the pre-flash compensation function, where the pre-flash compensation function is a cubic polynomial function.

[0070] In some embodiments, the parameter determination module is configured to:

[0071] Determining, based on the ambient light brightness of the current ambient light, a flash sensitivity parameter corresponding to the ambient light brightness;

[0072] Based on the flash sensitivity parameter, a weighted sum is performed on the first white balance parameter and the third white balance parameter to obtain the target white balance parameter.

[0073] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0074] processor;

[0075] a memory for storing processor-executable instructions;

[0076] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure.

[0077] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method described in the first aspect of the embodiment of the present disclosure.

[0078] The above method of the present disclosure has the following beneficial effects:

[0079] The method provided by the embodiment of the present disclosure compensates the second white balance parameter of the flash during pre-flash through a pre-flash compensation function to obtain a more accurate third white balance parameter, thereby reducing the white balance difference between the flash pre-flash and the flash main flash, so that the target white balance parameter determined based on the first white balance parameter and the third white balance parameter is more accurate, thereby improving the accuracy of the flash white balance and avoiding the problem of color cast during flash photography.

[0080] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0081] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0082] Figure 1 is a flow chart showing a white balance compensation method according to an exemplary embodiment;

[0083] Figure 2 is a flow chart showing a white balance compensation method according to an exemplary embodiment;

[0084] Figure 3 is a flow chart showing a function fitting process according to an exemplary embodiment;

[0085] Figure 4 is a block diagram of a white balance compensation device according to an exemplary embodiment;

[0086] Figure 5 is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0087] Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. In the following description, when referring to the drawings, like numbers in different figures represent like or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all possible embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present invention, as detailed in the appended claims.

[0088] In order to address the problem of color cast when shooting with flash due to poor accuracy of flash white balance, a related technology adjusts the pre-flash color temperature to the color temperature of the current ambient light by adjusting the current ratio of the high color temperature LED (Light Emitting Diode) and the low color temperature LED. During the adjustment, focus distance information is required, and the main flash fill light can only be executed when the current ratio of the high color temperature LED and the low color temperature LED is the same as the pre-flash. This greatly prolongs the flash shooting time and increases the power consumption of the device.

[0089] In another related technology, a dual-channel driving current is output to a dual-color temperature flash through a dual-channel driving chip. If the ambient color temperature changes, the dual-channel driving current will jump, causing the current value obtained by the dual-color temperature flash to not match the current ambient color temperature. At the same time, if the shooting distance changes but the ambient color temperature does not change, and the dual-color temperature current value does not change, the image will be overexposed or color cast.

[0090] The aforementioned related art methods are not suitable for flash photography with a fixed current, and even if the current is not fixed, the aforementioned related art methods still have other problems. If the flash is a single-color LED flash, the aforementioned related art methods are also not applicable, and cannot improve the color cast problem that occurs when flash photography is used.

[0091] The method provided by the embodiment of the present disclosure compensates the white balance parameters of the flash during pre-flash through a pre-flash compensation function, thereby obtaining more accurate white balance parameters, improving the accuracy of the flash white balance, and avoiding the problem of color cast during flash photography.

[0092] The method provided in the embodiment of the present disclosure is executed by an electronic device, which may be a mobile phone, a tablet computer, a wearable device, a smart home device, or other device with a flash photography function.

[0093] Figure 1 is a flowchart of a white balance compensation method according to an exemplary embodiment, which is executed by an electronic device. Figure 1 , the method comprises the following steps:

[0094] Step S101 , obtaining a first white balance parameter when shooting under current ambient light, where the first white balance parameter is determined based on a white balance parameter when shooting with the flash on and a white balance parameter when shooting with the flash off.

[0095] In the disclosed embodiment, when shooting an image with the flash on, in order to obtain accurate white balance parameters, the white balance parameters for shooting with the flash off, shooting with the flash pre-flash on, and shooting with the flash main flash on are obtained. Shooting with the flash off means shooting under the current ambient light, shooting with the flash pre-flash on means shooting with the flash pre-flash on, and shooting with the flash main flash on means shooting with the flash main flash on.

[0096] The white balance parameters include a first ratio and a second ratio. The first ratio is the ratio between the first channel parameter and the second channel parameter in the pixel parameters, and the second ratio is the ratio between the third channel parameter and the second channel parameter in the pixel parameters. For example, if the first channel parameter is the R (red) value, the second channel parameter is the G (green) value, and the third channel parameter is the B (blue) value, the first ratio is the R / G value, and the second ratio is the B / G value. Optionally, the white balance parameters may also be referred to as AWB (Automatic White Balance) decision points.

[0097] The first white balance parameter is a blend of the white balance parameters for shooting with the flash on (main flash) and the white balance parameters for shooting with the flash off. The white balance parameter for shooting with the flash on (main flash) is dependent on the flash's hardware conditions and, if the flash's hardware conditions remain unchanged, is a fixed value. The white balance parameter for shooting with the flash off (off) is dependent on the current ambient light brightness and changes with changes in ambient light brightness.

[0098] Step S102 , obtaining a second white balance parameter when shooting under the current ambient light, where the second white balance parameter is a white balance parameter when shooting with the flash pre-flash turned on.

[0099] The second white balance parameter is a white balance parameter when the flash pre-flash is turned on for shooting. The second white balance parameter is related to the ambient light brightness of the current ambient light and changes with the change of the ambient light brightness.

[0100] Step S103 : Compensating the second white balance parameter based on a pre-flash compensation function to obtain a third white balance parameter. The pre-flash compensation function is obtained by fitting the white balance parameters obtained when shooting under different ambient light conditions.

[0101] In the disclosed embodiment, considering that the second white balance parameters may deviate when the shooting distance changes or when the color temperature is warmer or cooler, resulting in inaccurate final white balance parameters, the second white balance parameters are compensated based on a pre-flash compensation function to obtain more accurate third white balance parameters. This pre-flash compensation function is fitted based on white balance parameters acquired when shooting under different ambient lighting conditions.

[0102] Step S104 : determining a target white balance parameter based on the first white balance parameter and the third white balance parameter, where the target white balance parameter is used to perform white balance processing on the image to be processed.

[0103] If the third white balance parameter is more accurate, the target white balance parameter determined based on the first and third white balance parameters is also more accurate. White balance processing of the image to be processed based on the target white balance parameter can produce an image with a better display effect. The image to be processed is an image captured under the current ambient light.

[0104] The method provided by the embodiment of the present disclosure compensates the second white balance parameter of the flash during pre-flash through a pre-flash compensation function to obtain a more accurate third white balance parameter, thereby reducing the white balance difference between the flash pre-flash and the flash main flash, so that the target white balance parameter determined based on the first white balance parameter and the third white balance parameter is more accurate, thereby improving the accuracy of the flash white balance and avoiding the problem of color cast during flash photography.

[0105] Figure 2 is a flowchart of a white balance compensation method according to an exemplary embodiment, which is executed by an electronic device. Figure 2 , the method comprises the following steps:

[0106] Step S201: Acquire a pre-stored fourth white balance parameter.

[0107] The fourth white balance parameter is the white balance parameter when the flash is used for main flash shooting, and the ambient light is completely dark. That is, the fourth white balance parameter is affected by the main flash of the flash, but not by the ambient light. This fourth white balance parameter can also be called the AWB decision point of the main flash (i.e., the Flash MWB point).

[0108] In some embodiments, a first image is captured when the flash is turned on for main flash in a completely dark environment; a first ratio and a second ratio are determined based on pixel parameters of pixel points in a target area in the first image; wherein the pixel parameters include a first channel parameter, a second channel parameter, and a third channel parameter, the first ratio is a ratio between the first channel parameter and the second channel parameter, and the second ratio is a ratio between the third channel parameter and the second channel parameter; the first ratio and the second ratio are determined as a fourth white balance parameter, that is, the fourth white balance parameter includes the first ratio and the second ratio.

[0109] Optionally, a gray card with 100% FOV (Field of View) is photographed in a completely dark environment with the flash on for main flash, to obtain a first image, which is a RAW (an undistorted image format) image.

[0110] Optionally, the target area is a central area in the first image, for example, the target area is an area 20%-30% of the center of the first image. Determining the first ratio and the second ratio based on pixel parameters of pixels in the target area in the first image includes: determining an average pixel parameter of the pixels in the target area, determining a ratio between a first channel parameter and a second channel parameter in the average pixel parameter as the first ratio, and determining a ratio between a third channel parameter and the second channel parameter in the average pixel parameter as the second ratio.

[0111] Step S202 : obtaining first log information when shooting with the flash turned off under current ambient light, and obtaining a fifth white balance parameter from the first log information.

[0112] The first log information includes a fifth white balance parameter, which is a white balance parameter when shooting with the flash off under the current ambient light. The fifth white balance parameter can also be called the AWB decision point of the ambient light (ie, LED off point).

[0113] Step S203: Determine the first white balance parameter based on the fourth white balance parameter and the fifth white balance parameter.

[0114] In some embodiments, based on the ambient light brightness of the current ambient light, a flash sensitivity parameter corresponding to the ambient light brightness is determined, wherein there is a corresponding relationship between the flash sensitivity parameter and the ambient light brightness; based on the flash sensitivity parameter, a weighted sum is performed on the fourth white balance parameter and the fifth white balance parameter to obtain the first white balance parameter.

[0115] Optionally, performing a weighted summation of the fourth white balance parameter and the fifth white balance parameter based on the flash sensitivity parameter to obtain the first white balance parameter includes: determining a first weight for the fourth white balance parameter and a second weight for the fifth white balance parameter based on the flash sensitivity parameter, where the sum of the first weight and the second weight is 1; and then performing a weighted summation of the fourth white balance parameter and the fifth white balance parameter based on the first weight and the second weight to obtain the first white balance parameter. For example, the first white balance parameter is determined using the following formula:

[0116] interMWB=Flash MWB point*flashManualRatio+LED off point*(1

[0117] -flashManualRatio)

[0118] Among them, interMWB represents the first white balance parameter, Flash MWB point represents the fourth white balance parameter, flashManualRatio represents the first weight, LED off point represents the fifth white balance parameter, and 1-flashManualRatio represents the second weight.

[0119] Optionally, an AEC (Automatic Exposure Control) module determines a flash sensitivity parameter based on ambient light brightness.

[0120] Step S204: Acquire a pre-stored sixth white balance parameter.

[0121] The sixth white balance parameter is a white balance parameter when shooting with the flash pre-flash turned on in a completely dark environment.

[0122] In some embodiments, a second log message is obtained when a flash pre-flash is activated in a completely dark environment; and a sixth white balance parameter is obtained from the second log message. The second log message includes the sixth white balance parameter, which is the white balance parameter when the flash pre-flash is activated in the current environment. The sixth white balance parameter can also be referred to as a pre-flash reference point (i.e., a pre-flash MWB target point).

[0123] Step S205 : determining a second white balance parameter based on the sixth white balance parameter, the ambient light brightness of the current ambient light, and the pre-flash valid statistical data points.

[0124] The pre-flash valid statistical data points include data points located in a preset gray area in the coordinate system. The data points in the coordinate system are determined based on the pixel parameters of the pixel points when the flash pre-flash is turned on under the current ambient light. The horizontal coordinate of the coordinate system is the ratio between the first channel parameter and the second channel parameter in the pixel parameters, and the vertical coordinate of the coordinate system is the ratio between the third channel parameter and the second channel parameter in the pixel parameters. The horizontal coordinate of the data point corresponding to the pixel point in the coordinate system is the ratio between the first channel parameter and the second channel parameter in the pixel parameters of the pixel point, and the vertical coordinate is the ratio between the third channel parameter and the second channel parameter in the pixel parameters of the pixel point.

[0125] Optionally, a preset calculation formula is used to calculate the sixth white balance parameter, the ambient light brightness of the current ambient light, and the pre-flash valid statistical data points to obtain a second white balance parameter. The second white balance parameter can also be called the pre-flash AWB decision point (i.e., preflash preview point).

[0126] Step S206 : Using the first ratio in the second white balance parameter as an input of the pre-flash compensation function to obtain a second ratio output by the pre-flash compensation function.

[0127] The pre-flash compensation function is a cubic polynomial function, in which the independent variable is the first ratio and the dependent variable is the second ratio. For example, the pre-flash compensation function is as follows:

[0128] K=σ1X 3 +σ2X 2 +σ3X+μ

[0129] Wherein, K represents the second ratio, X represents the first ratio, and σ1, σ2, σ3, and μ are fixed coefficients.

[0130] The second ratio is determined using the following formula:

[0131] preflash preview point (B / G) new =σ1(R / G) origin 3 +σ2(R / G) origin 2 +σ3(R / G) origin +μ

[0132] Among them, preflash preview point (B / G) new is the second ratio of the output, (R / G) origin is the first ratio in the second white balance parameter.

[0133] Step S207 : Determine the first ratio in the second white balance parameter and the second ratio output by the pre-flash compensation function as a third white balance parameter.

[0134] Step S208 : determining a flash sensitivity parameter corresponding to the current ambient light brightness based on the ambient light brightness.

[0135] Step S209 : performing weighted summation on the first white balance parameter and the third white balance parameter based on the flash sensitivity parameter to obtain a target white balance parameter.

[0136] The implementation of steps S208 and S209 is similar to the implementation of determining the first white balance parameter in step S203.

[0137] Optionally, based on the flash sensitivity parameter, performing a weighted summation on the first white balance parameter and the third white balance parameter to obtain the target white balance parameter includes: determining a third weight for the first white balance parameter and a fourth weight for the third white balance parameter based on the flash sensitivity parameter, where the sum of the third weight and the fourth weight is 1; and then performing a weighted summation on the first white balance parameter and the third white balance parameter based on the third weight and the fourth weight to obtain the target white balance parameter. For example, the target white balance parameter is determined using the following formula:

[0138] finalPreflash=interMWB*preFlashMixRatio+preflash preview point new *(1

[0139] -preFlashMixRatio)

[0140] Among them, finalPreflash represents the target white balance parameter, interMWB represents the first white balance parameter, preFlashMixRatio represents the third weight, and preflash preview point new represents the third white balance parameter, and 1-preFlashMixRatio represents the fourth weight.

[0141] Step S210 : performing white balance processing on the image to be processed based on the target white balance parameters to obtain a target image.

[0142] Among them, the image to be processed is the image that has not been white balanced. Based on the target white balance parameters, the white balance of each pixel in the image to be processed is adjusted to obtain the target image. Compared with the image to be processed, the target image is closer to the color of the actual shooting scene.

[0143] The method provided by the disclosed embodiments uses a pre-flash compensation function to compensate for the second white balance parameter during a flash pre-flash, resulting in a more accurate third white balance parameter. This reduces the white balance difference between the flash pre-flash and the main flash, thereby making the target white balance parameter determined based on the first and third white balance parameters more accurate. This improves the accuracy of the flash white balance and avoids color cast issues during flash photography. Furthermore, the color matching between flash photography and actual scene photography is improved, and the display quality of the target image processed based on the target white balance parameter is also enhanced.

[0144] Figure 3 is a flow chart showing a function fitting process according to an exemplary embodiment, which is executed by an electronic device, see Figure 3 , the method comprises the following steps:

[0145] Step S301 , obtaining a first white balance parameter and a second white balance parameter when shooting under different ambient light conditions.

[0146] In the disclosed embodiment, the pre-flash compensation function is obtained by pre-fitting. Since the pre-flash compensation function is intended to reduce the white balance difference between the flash pre-flash and the flash main flash, the relationship between the white balance parameters during flash pre-flash shooting and the white balance parameters during flash main flash shooting must be considered when fitting the pre-flash compensation function.

[0147] above Figure 2 In the embodiment shown, the first and second white balance parameters determined are the white balance parameters when the image to be processed is captured under the current ambient light. However, fitting the pre-flash compensation function needs to take into account a variety of ambient light conditions. Therefore, it is necessary to obtain the first and second white balance parameters when capturing images under different ambient light conditions. The first and second white balance parameters when capturing images under each ambient light condition are obtained in the same manner as described above. Figure 2 In the illustrated embodiment, the method for obtaining the first white balance parameter and the second white balance parameter when shooting under the current ambient light is similar and will not be described in detail here.

[0148] Step S302 : Fitting the first white balance parameter and the second white balance parameter when shooting under different ambient light conditions to obtain a pre-flash compensation function.

[0149] Based on the distribution characteristics of the plurality of first white balance parameters and the plurality of second white balance parameters in the coordinate system, a pre-flash compensation function is obtained by fitting.

[0150] In the embodiment of the present disclosure, the pre-flash compensation function is used to compensate the white balance parameters during the flash pre-flash to reduce the white balance difference between the flash pre-flash and the flash main flash, thereby obtaining more accurate white balance parameters during flash pre-flash shooting.

[0151] Figure 4 is a block diagram of a white balance compensation device according to an exemplary embodiment, which is configured in an electronic device. Figure 4 , the device comprises:

[0152] A first parameter acquisition module 401 is configured to acquire a first white balance parameter when shooting under current ambient light, where the first white balance parameter is determined based on a white balance parameter when shooting with the flash on and a white balance parameter when shooting with the flash off;

[0153] The second parameter acquisition module 402 is configured to acquire a second white balance parameter when shooting under the current ambient light, where the second white balance parameter is a white balance parameter when shooting with the flash pre-flash turned on;

[0154] The white balance compensation module 403 is configured to compensate the second white balance parameter based on a pre-flash compensation function to obtain a third white balance parameter, where the pre-flash compensation function is obtained by fitting the white balance parameters obtained when shooting under different ambient light conditions;

[0155] The parameter determination module 404 is configured to determine a target white balance parameter based on the first white balance parameter and the third white balance parameter, where the target white balance parameter is used to perform white balance processing on the image to be processed.

[0156] In some embodiments, the first parameter acquisition module 401 is configured to:

[0157] Obtaining a pre-stored fourth white balance parameter, where the fourth white balance parameter is a white balance parameter when the flash is turned on for main flash shooting;

[0158] Get the first log information when shooting with the flash off under the current ambient light;

[0159] Obtaining a fifth white balance parameter from the first log information;

[0160] Based on the fourth white balance parameter and the fifth white balance parameter, a first white balance parameter is determined.

[0161] In some embodiments, the apparatus further comprises:

[0162] An image capture module is configured to capture a first image when the flash is turned on for main flash in a completely dark environment;

[0163] a ratio determination module configured to determine a first ratio and a second ratio based on pixel parameters of pixel points in the target area in the first image; wherein the pixel parameters include a first channel parameter, a second channel parameter, and a third channel parameter, the first ratio is a ratio between the first channel parameter and the second channel parameter, and the second ratio is a ratio between the third channel parameter and the second channel parameter;

[0164] The third parameter acquisition module is further configured to determine the first ratio and the second ratio as a fourth white balance parameter.

[0165] In some embodiments, the first parameter acquisition module 401 is configured to:

[0166] Based on the current ambient light brightness, determine the flash sensitivity parameter corresponding to the ambient light brightness;

[0167] Based on the flash sensitivity parameter, a weighted sum is performed on the fourth white balance parameter and the fifth white balance parameter to obtain the first white balance parameter.

[0168] In some embodiments, the second parameter acquisition module 402 is configured to:

[0169] Obtaining a pre-stored sixth white balance parameter, where the sixth white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on in a completely dark environment;

[0170] determining a second white balance parameter based on the sixth white balance parameter, the ambient light brightness of the current ambient light, and the pre-flash valid statistical data points;

[0171] Among them, the pre-flash effective statistical data points include data points located in a preset gray area in the coordinate system, and the data points in the coordinate system are determined based on the pixel parameters of the pixel points when the flash pre-flash is turned on under the current ambient light. The horizontal coordinate of the coordinate system is the ratio between the first channel parameter and the second channel parameter in the pixel parameters, and the vertical coordinate of the coordinate system is the ratio between the third channel parameter and the second channel parameter in the pixel parameters.

[0172] In some embodiments, the apparatus further comprises:

[0173] a log acquisition module configured to acquire second log information when a flash pre-flash is turned on to shoot in a completely dark environment;

[0174] The fourth parameter acquisition module is configured to acquire a sixth white balance parameter from the second log information.

[0175] In some embodiments, the white balance parameter includes a first ratio and a second ratio, the first ratio being a ratio between a first channel parameter and a second channel parameter in the pixel parameters, and the second ratio being a ratio between a third channel parameter and the second channel parameter in the pixel parameters;

[0176] The white balance compensation module 403 is configured to:

[0177] using the first ratio in the second white balance parameter as an input of a pre-flash compensation function to obtain a second ratio output by the pre-flash compensation function;

[0178] The first ratio in the second white balance parameter and the second ratio output by the pre-flash compensation function are determined as the third white balance parameter.

[0179] In some embodiments, the apparatus further comprises:

[0180] a fifth parameter acquisition module, configured to acquire a first white balance parameter and a second white balance parameter when shooting under different ambient light conditions;

[0181] The compensation function determination module is configured to fit the first white balance parameter and the second white balance parameter when shooting under different ambient light conditions to obtain a pre-flash compensation function, where the pre-flash compensation function is a cubic polynomial function.

[0182] In some embodiments, the parameter determination module 404 is configured to:

[0183] Based on the current ambient light brightness, determine the flash sensitivity parameter corresponding to the ambient light brightness;

[0184] Based on the flash sensitivity parameter, a weighted sum is performed on the first white balance parameter and the third white balance parameter to obtain a target white balance parameter.

[0185] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0186] An embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the white balance compensation method in the above embodiment.

[0187] Figure 5 is a block diagram of an electronic device 500 according to an exemplary embodiment.

[0188] Reference Figure 5 , the electronic device 500 may include one or more of the following components: a processing component 502 , a memory 504 , a power component 506 , a multimedia component 508 , an audio component 510 , an input / output (I / O) interface 512 , a sensor component 514 , and a communication component 516 .

[0189] The processing component 502 generally controls the overall operation of the electronic device 500, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component 502 may include one or more processors 620 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 502 may include one or more modules to facilitate interaction between the processing component 502 and other components. For example, the processing component 502 may include a multimedia module to facilitate interaction between the multimedia component 508 and the processing component 502.

[0190] The memory 504 is configured to store various types of data to support operations on the electronic device 500. Examples of such data include instructions for any application or method operating on the electronic device 500, contact data, phone book data, messages, pictures, videos, etc. The memory 504 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.

[0191] The power supply assembly 506 provides power to the various components of the electronic device 500. The power supply assembly 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 500.

[0192] The multimedia component 508 includes a screen that provides an output interface between the electronic device 500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor can not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front camera and / or a rear camera. When the electronic device 500 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have a focal length and optical zoom capability.

[0193] The audio component 510 is configured to output and / or input audio signals. For example, the audio component 510 includes a microphone (MIC), which is configured to receive external audio signals when the electronic device 500 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in the memory 504 or transmitted via the communication component 516. In some embodiments, the audio component 510 also includes a speaker for outputting audio signals.

[0194] I / O interface 512 provides an interface between processing component 502 and peripheral interface modules, such as a keyboard, click wheel, buttons, etc. These buttons may include but are not limited to: a home button, volume buttons, a start button, and a lock button.

[0195] The sensor assembly 514 includes one or more sensors for providing various aspects of status assessment for the electronic device 500. For example, the sensor assembly 514 can detect the open / closed state of the electronic device 500, the relative positioning of components, such as the display and keypad of the electronic device 500. The sensor assembly 514 can also detect changes in the position of the electronic device 500 or a component of the electronic device 500, the presence or absence of user contact with the electronic device 500, the orientation or acceleration / deceleration of the electronic device 500, and temperature changes of the electronic device 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 514 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0196] The communication component 516 is configured to facilitate wired or wireless communication between the electronic device 500 and other devices. The electronic device 500 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0197] In an exemplary embodiment, the electronic device 500 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0198] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 504 including instructions, and the instructions can be executed by the processor 620 of the electronic device 500 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0199] The embodiments of the present disclosure further provide a non-transitory computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the white balance compensation method in the above embodiment.

[0200] Other embodiments of the present invention will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the invention being indicated by the following claims.

[0201] It should be understood that the present invention is not limited to the exact construction described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A white balance compensation method, characterized in that: The method comprises: Obtaining a first white balance parameter when shooting under the current ambient light, where the first white balance parameter is determined based on a white balance parameter when shooting with the flash on and a white balance parameter when shooting with the flash off; Acquire a second white balance parameter when shooting under the current ambient light, where the second white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on; Compensating the second white balance parameter based on a pre-flash compensation function to obtain a third white balance parameter, wherein the pre-flash compensation function is obtained by fitting the white balance parameters obtained when shooting under different ambient light conditions; A target white balance parameter is determined based on the first white balance parameter and the third white balance parameter, and the target white balance parameter is used to perform white balance processing on the image to be processed.

2. The method according to claim 1, characterized in that The obtaining of a first white balance parameter when shooting under the current ambient light includes: Obtaining a pre-stored fourth white balance parameter, wherein the fourth white balance parameter is a white balance parameter when the flash is turned on for main flash shooting; Obtaining first log information when shooting with the flash turned off under the current ambient light; Obtaining a fifth white balance parameter from the first log information; The first white balance parameter is determined based on the fourth white balance parameter and the fifth white balance parameter.

3. The method according to claim 2, characterized in that The method further comprises: The first image is captured in total darkness with the flash firing. determining a first ratio and a second ratio based on pixel parameters of pixel points in the target area in the first image; wherein the pixel parameters include a first channel parameter, a second channel parameter, and a third channel parameter, the first ratio is a ratio between the first channel parameter and the second channel parameter, and the second ratio is a ratio between the third channel parameter and the second channel parameter; The first ratio and the second ratio are determined as the fourth white balance parameter.

4. The method according to claim 2, characterized in that The determining the first white balance parameter based on the fourth white balance parameter and the fifth white balance parameter includes: Determining, based on the ambient light brightness of the current ambient light, a flash sensitivity parameter corresponding to the ambient light brightness; Based on the flash sensitivity parameter, a weighted sum is performed on the fourth white balance parameter and the fifth white balance parameter to obtain the first white balance parameter.

5. The method according to claim 1, wherein The acquiring of a second white balance parameter when shooting under the current ambient light includes: Obtaining a pre-stored sixth white balance parameter, wherein the sixth white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on in a completely dark environment; determining the second white balance parameter based on the sixth white balance parameter, the ambient light brightness of the current ambient light, and pre-flash valid statistical data points; Among them, the pre-flash effective statistical data points include data points located in a preset gray area in the coordinate system, and the data points in the coordinate system are determined based on the pixel parameters of the pixel points when the flash pre-flash is turned on under the current ambient light. The horizontal coordinate of the coordinate system is the ratio between the first channel parameter and the second channel parameter in the pixel parameters, and the vertical coordinate of the coordinate system is the ratio between the third channel parameter and the second channel parameter in the pixel parameters.

6. The method according to claim 5, characterized in that The method further comprises: Get the second log information when shooting with the flash pre-flash in complete darkness; Acquire a sixth white balance parameter from the second log information.

7. The method according to claim 1, characterized in that The white balance parameter includes a first ratio and a second ratio, wherein the first ratio is a ratio between a first channel parameter and a second channel parameter in the pixel parameters, and the second ratio is a ratio between a third channel parameter and a second channel parameter in the pixel parameters; The compensating the second white balance parameter based on the pre-flash compensation function to obtain the third white balance parameter includes: using the first ratio of the second white balance parameter as an input of the pre-flash compensation function to obtain a second ratio output by the pre-flash compensation function; The first ratio of the second white balance parameter and the second ratio output by the pre-flash compensation function are determined as the third white balance parameter.

8. The method according to claim 1, wherein: The method further comprises: Obtaining first and second white balance parameters when shooting under different ambient light conditions; The first white balance parameter and the second white balance parameter when shooting under the different ambient light conditions are fitted to obtain the pre-flash compensation function, where the pre-flash compensation function is a cubic polynomial function.

9. The method according to claim 1, characterized in that The determining of a target white balance parameter based on the first white balance parameter and the third white balance parameter includes: Determining, based on the ambient light brightness of the current ambient light, a flash sensitivity parameter corresponding to the ambient light brightness; Based on the flash sensitivity parameter, a weighted sum is performed on the first white balance parameter and the third white balance parameter to obtain the target white balance parameter.

10. A white balance compensation device, characterized in that: The device comprises: A first parameter acquisition module is configured to acquire a first white balance parameter when shooting under current ambient light, where the first white balance parameter is determined based on a white balance parameter when shooting with the flash on and a white balance parameter when shooting with the flash off; A second parameter acquisition module is configured to acquire a second white balance parameter when shooting under the current ambient light, wherein the second white balance parameter is a white balance parameter when shooting with a flash pre-flash turned on; a white balance compensation module configured to compensate the second white balance parameter based on a pre-flash compensation function to obtain a third white balance parameter, wherein the pre-flash compensation function is obtained by fitting the white balance parameters obtained when shooting under different ambient light conditions; The parameter determination module is configured to determine a target white balance parameter based on the first white balance parameter and the third white balance parameter, where the target white balance parameter is used to perform white balance processing on the image to be processed.

11. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 9.

12. A non-transitory computer-readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 9.