Image processing method and device, equipment and medium
By dividing the same color temperature region of the image into multiple sub-regions, and calculating and applying different compensation coefficients for white balance correction, the problem of image color casting in the prior art is solved, and a more accurate white balance processing effect is achieved.
Patent Information
- Application Number
- CN202510887609.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-08-29
AI Technical Summary
The existing automatic white balance algorithm based on brightness and color temperature cannot accurately restore the colors of the real scene in the image, resulting in color casting problems in different images after white balance processing.
The same color temperature region of the image to be processed is divided into multiple sub-regions, and the compensation coefficients of the spatial gain and preference gain of each sub-region are calculated separately. The white balance gain of each sub-region is determined through segmented calculations to use different compensation coefficients to perform white balance correction at different sub-regions.
It improves the accuracy of white balance processing, reduces color conflict problems in the same color temperature area, and can restore image colors more realistically, adapt to various white balance scenes, including single light sources and multiple light sources shooting scenes.
Smart Images

Figure CN120568035A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, apparatus, device and medium. Background Art
[0002] Automatic white balance (AWB) is widely used in image processing. During image AWB processing, the AWB algorithm differentiates compensation coefficients based on the image's brightness and color temperature. This processing method results in the same compensation coefficients for different images with the same brightness and color temperature. However, using the same compensation coefficients for different images can produce significantly different white balance results, resulting in different color casts (for example, cyan or reddish). Therefore, current AWB algorithms based on brightness and color temperature cannot accurately restore the colors of the actual scene in the image. Summary of the Invention
[0003] Based on this, it is necessary to provide an image processing method, device, equipment and medium to address the above technical problems.
[0004] The present invention provides an image processing method, which includes:
[0005] Divide the same color temperature area of the image to be processed into multiple sub-areas;
[0006] For each of the sub-regions, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain;
[0007] determining a white balance gain for each of the sub-regions based on the first compensation coefficient and the second compensation coefficient corresponding to each of the sub-regions;
[0008] White balance correction is performed on the image to be processed according to the white balance gain of each sub-region.
[0009] An embodiment of the present application provides an image processing device, the device comprising:
[0010] A region division module is used to divide the same color temperature region of the image to be processed into multiple sub-regions;
[0011] a compensation coefficient determination module, configured to determine, for each of the sub-regions, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain;
[0012] a white balance gain determination module, configured to determine a white balance gain for each of the sub-regions based on the first compensation coefficient and the second compensation coefficient corresponding to each of the sub-regions;
[0013] The white balance correction module is configured to perform white balance correction on the image to be processed according to the white balance gain of each sub-region.
[0014] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the image processing method provided in any embodiment of the present application are implemented.
[0015] An embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the image processing method provided in any embodiment of the present application are implemented.
[0016] An image processing method, apparatus, device, and medium provided by the embodiments of the present application include: dividing the same color temperature area of an image to be processed into multiple sub-areas; for each sub-area, determining a first compensation coefficient corresponding to a spatial gain and a second compensation coefficient corresponding to a preference gain; determining a white balance gain for each sub-area based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-area; and performing white balance correction on the image to be processed according to the white balance gain of each sub-area.
[0017] This technical solution divides the same color temperature area of the image to be processed into multiple sub-areas, so that the first compensation coefficient of the spatial gain and the second compensation coefficient of the preference gain can be calculated in segments. On this basis, the respective white balance gain is determined for each sub-area, so that the compensation coefficients in the same color temperature area are calculated differently according to the differences in the sub-areas. Different compensation coefficients are used in different sub-areas, which is conducive to improving the accuracy of the calculated white balance gain, and can effectively improve the color conflict problem existing in the same color temperature area, which is conducive to more realistic restoration of image colors and improved white balance processing effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 1 is a flow chart of an image processing method according to an embodiment;
[0019] Figure 2 is a schematic diagram of a compensation coefficient in one embodiment;
[0020] Figure 3 FIG1 is a schematic diagram of a process for determining a white balance gain in one embodiment;
[0021] Figure 4 is a schematic structural diagram of an image processing device in one embodiment;
[0022] Figure 5 FIG. 1 is a schematic structural diagram of an electronic device in an embodiment. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0024] Currently, the AWB algorithm based on brightness and color temperature cannot accurately restore the colors of the real scene in the image.
[0025] One related AWB correction implementation involves averaging the (R, G, B) components of each pixel in the image to derive gain values for the (R, G, B) channels, namely R-gain, G-gain, and B-gain. These gains are then multiplied by the (R, G, B) values of each pixel in the image to correct for color deviations caused by the light source color, thereby completing AWB correction. This approach makes AWB correction susceptible to the color of objects within the image, reducing its accuracy.
[0026] Another related image AWB processing method is to differentiate compensation coefficients based on brightness and color temperature regions. This method is used to perform AWB processing on two images with different scenes. The information of the two images can be seen in Table 1 below.
[0027] Table 1
[0028] brightness Light source P_TL84 Light source P_CWF Light source P_D65 Light source P_D70 Image A 142 7% 3% 91% 0 Image B 142 6% 6% 87% 1%
[0029] Since image A and image B have the same brightness (both are 142), the calculated compensation coefficient is the same; however, after processing with this compensation coefficient, the colors of the two images will be biased in different directions: image A will be cyan and image B will be reddish.
[0030] As can be seen from the image information shown in Table 1 above, the brightness of Image A and Image B is both 142, and the light source D65 accounts for the majority of the light source. Therefore, the color difference between the two images mainly depends on the AWB gain value of the light source D65.
[0031] Combined with Table 2, the present disclosure analyzes the reason why the colors of the two images deviate in different directions: the two images of different scenes have the same spatial gain (spa_gain) and preference gain (pref_gain) for the same brightness and color temperature compensation. Therefore, the AWB gain cannot take into account the two different scenes. As a result, the colors of some scenes cannot be accurately restored, and the image after white balance processing still has color cast problems.
[0032] Table 2
[0033]
[0034] The gain values at each stage of the image show that the image differences are primarily due to statistical gain (sta_gain), which is derived from the location of the landing point and cannot be changed. However, this disclosure considers compensating for spatial gain and preference gain to optimize parameters for different AWB coordinates within the same brightness and color temperature region.
[0035] Based on the above-mentioned image AWB processing method, the present disclosure provides an image processing method, apparatus, device, and medium. When calculating spatial gain and preference gain, this technical solution extracts the average AWB coordinate within the color temperature region and determines the spatial gain and preference gain in segments based on the different AWB coordinates. In other words, the compensation coefficients within the same color temperature region are calculated separately based on the differences in AWB coordinates, and different compensation coefficients are used at different AWB coordinates. This approach can reduce color conflicts between different AWB coordinates within the same color temperature region.
[0036] To facilitate understanding of the solution, this embodiment first describes the image processing method.
[0037] like Figure 1 As shown, this embodiment provides an image processing method, which can be adapted to the ISPPipeline (image signal processing pipeline) of various chip platforms on the market, and is used in scenarios where white balance processing of images is performed. The method can be executed by an image processing device, which can be implemented using software and / or hardware methods and can be integrated into an electronic device. Among them, the electronic device can be, for example, a smartphone, a personal computer, a laptop, a tablet computer, and a portable wearable device. Figure 1 , the image processing method may include the following steps.
[0038] S102: Divide the same color temperature area of the image to be processed into multiple sub-areas.
[0039] The image to be processed may be an image acquired under multiple different light sources, such as D65, CWF, and D70. Each light source is calibrated with a corresponding color temperature region on the image to be processed.
[0040] In this embodiment, the statistical coordinates of each type of light source and the coordinates of the color temperature region of the image to be processed may be read separately by using the MTK Debugparser tool.
[0041] It is understood that the processing method for each type of light source is the same, and the light source D65 is used as an example for description. The statistical coordinates of the light source D65 in the image to be processed can be referred to the example in the following Table 3.
[0042] Table 3
[0043] Image to be processed AWB_TAG_AVG_XR_D65 AWB_TAG_AVG_YR_D65 Illuminant D65 47 -283
[0044] In Table 3 above, AWB_TAG_AVG_XR_D65 and AWB_TAG_AVG_YR_D65 are statistical parameters related to automatic white balance. They describe the color distribution characteristics of the processed image under illuminant D65 and represent the offset of the average chromaticity coordinates of the color temperature region in the processed image in the RGB color space. Based on the XR in AWB_TAG_AVG_XR_D65, this parameter indicates the red offset of the average chromaticity coordinates of the color temperature region in the processed image in the RGB color space. The value of this parameter in Table 3 is 47, indicating an increase in red (towards warmer tones). Similarly, AWB_TAG_AVG_YR_D65 indicates the yellow / green offset of the average chromaticity coordinates of the color temperature region in the processed image in the RGB color space. The value of this parameter in Table 3 is -283, indicating that the yellow / green components are below the D65 standard and are weakened (towards cooler tones).
[0045] The coordinates of the color temperature region of the light source D65 in the image to be processed can be referred to the example in Table 4 below.
[0046] Table 4
[0047] Color temperature range of light source D65 coordinate AWB_NVRAM_D65_RIGHT 166 AWB_NVRAM_D65_LEFT 16 AWB_NVRAM_D65_UPPER -218 AWB_NVRAM_D65_LOWER -344
[0048] In this embodiment, the color temperature region of the light source D65 is a reference region predefined or calibrated by the AWB algorithm under the D65 standard light source, and is used to calculate the average pixel value (such as chromaticity coordinates XR and YR) in the region.
[0049] For the same color temperature region, since the brightness is the same, the compensation coefficient calculated using the existing AWB algorithm is the same for the color temperature region, which may lead to inaccurate color reproduction.
[0050] To address this issue, this embodiment can divide the same color temperature region into multiple sub-regions, and calculate a compensation coefficient for each sub-region separately. In one implementation, the same color temperature region of the image to be processed can be divided into multiple sub-regions along a preset direction; the preset direction can be, for example, the horizontal coordinate direction (Xr) or the vertical coordinate direction (Yr) of the color temperature region, which is not limited here.
[0051] As an example, for a color temperature region corresponding to the light source D65 in the image to be processed, the color temperature region is evenly divided into three sub-regions along the horizontal axis direction.
[0052] Next, referring to the subsequent steps, the compensation coefficients of the spatial gain and the preference gain are adjusted for each sub-region.
[0053] S104: For each sub-region, determine a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain.
[0054] The implementation process of this embodiment may include: for each sub-region, determining the average AWB coordinate of the sub-region as a node for adjusting the compensation coefficient; for each node, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain based on the AWB parameter of the node.
[0055] Specifically, based on the above embodiment, the sub-areas are divided along the horizontal axis direction, so we only need to pay attention to the AWB coordinates in the horizontal axis direction. Figure 2 According to the example in Table 4 above, the coordinate of the left boundary of the color temperature region is 16, and the coordinate of the right boundary is 166. Within this range, from left to right, the average AWB coordinates of the three sub-regions are 41, 91, and 141, respectively. The AWB parameters of the average AWB coordinates of the above multiple sub-regions in the RGB color space are read. The AWB parameters may include the original spatial gain (R, G, B) and the original preference gain (R, G, B), as shown in Table 5 below.
[0056] Table 5
[0057]
[0058] In Table 5, the sub-region on the left is taken as an example. The original spatial gain of its average AWB coordinate (41) in the RGB color space is spatial gain (R, G, B) = (522, 512, 512), which means that the original spatial gain of the R channel is 562, the original spatial gain of the G channel is 512, and the original spatial gain of the B channel is 512; among them, the R channel is slightly enhanced, indicating a slight red shift.
[0059] In this case, for each node, an embodiment of determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain according to the AWB parameter of the node can refer to the following steps (1)-(3).
[0060] (1) Obtaining the AWB parameters of the node; wherein the AWB parameters include the original spatial gain and the original preference gain; for details, please refer to the example in Table 5 above, which will not be described in detail here.
[0061] (2) Determine a first compensation coefficient of the spatial gain based on a ratio between the original spatial gain and a preset basic parameter.
[0062] This embodiment may include: determining the ratio between the original spatial gain and the preset basic parameter as the key compensation coefficient of the spatial gain at the node; performing interpolation calculation between the key compensation coefficients of the spatial gain corresponding to each two adjacent nodes to obtain a first compensation coefficient of the spatial gain corresponding to each AWB coordinate within the color temperature area.
[0063] Specifically, according to the parameter characteristics of MTK (MediaTek Inc. MTK, referred to as MediaTek), 512 is used as the basic parameter (1.0 times), and the ratio between the original spatial gain and the preset basic parameter is determined as the key compensation coefficient of the spatial gain at the node.
[0064] Continuing with the example provided in Table 5, for the node in the left sub-region (AWB_TAG_AVG_XR_D65 = 41), the original spatial gain of the R channel is 562. The ratio between this original spatial gain and the basic parameter is used as the key compensation coefficient for spatial gain: ratio = 562 / 512 ≈ 1.097. Both the G and B channels are 512, and no gain adjustment is performed.
[0065] For the node of the middle sub-region (AWB_TAG_AVG_XR_D65=91), the R channel, G channel, and B channel are all 512, and no gain adjustment is required. The reason may be that the color temperature of this sub-region is close to the ideal D65 and no correction is required.
[0066] For the node in the right sub-area (AWB_TAG_AVG_XR_D65=141), its original spatial gain in the RGB color space is spatial gain(R,G,B)=(502, 512, 520). In the R channel, the ratio between its original spatial gain and the basic parameter is determined as the key compensation coefficient of the spatial gain, that is, ratio=(466 / 512≈0.91 times, which suppresses the red offset of the R channel. The G channel does not require gain adjustment. In the B channel, the ratio between its original spatial gain and the basic parameter is determined as the key compensation coefficient of the spatial gain, that is, ratio=(520 / 512≈1.016 times, which enhances the green offset of the B channel. In the sub-area on the right side of this embodiment, by adjusting the above key compensation coefficients, the sub-area can be corrected to a cool tone to balance the over-warming.
[0067] Then, combined Figure 2 , interpolate the key compensation coefficients of the spatial gain corresponding to each two adjacent nodes to obtain the first compensation coefficient of the spatial gain corresponding to each AWB coordinate in the color temperature area. Specifically, the key compensation coefficients of the spatial gain of the nodes in the two sub-areas on the left and in the middle are ratio respectively. 左 =1.097 and ratio中 =1, interpolation is performed between the two key compensation coefficients according to a preset interpolation algorithm, and then the interpolation result is smoothed to obtain the first compensation coefficient of the spatial gain corresponding to multiple AWB coordinates between 41 and 91.
[0068] According to the above embodiment, the first compensation coefficient of the spatial gain corresponding to each AWB coordinate within the color temperature region can be obtained. The first compensation coefficient of the spatial gain corresponding to each AWB coordinate within the color temperature region includes the first compensation coefficient of the spatial gain corresponding to the AWB coordinate (47) of the light source D65.
[0069] Furthermore, for the first compensation coefficients at the left and right boundaries in the color temperature area, this embodiment can determine the first compensation coefficient of the spatial gain corresponding to the node (41) of the left sub-area as the first compensation coefficient of the spatial gain corresponding to the AWB coordinate (16) of the left boundary of the color temperature area; and determine the first compensation coefficient of the spatial gain corresponding to the node (141) of the right sub-area as the first compensation coefficient of the spatial gain corresponding to the AWB coordinate (166) of the right boundary of the color temperature area.
[0070] (3) Based on the ratio between the original preference gain and the basic parameter, a second compensation coefficient of the preference gain is determined.
[0071] The implementation process of this embodiment is similar to the implementation process of determining the first compensation coefficient of the spatial gain mentioned above, mainly including: determining the ratio between the original preference gain and the preset basic parameter as the key compensation coefficient of the preference gain at the node; performing interpolation calculation between the key compensation coefficients of the preference gain corresponding to each two adjacent nodes to obtain the second compensation coefficient of the preference gain corresponding to each AWB coordinate in the color temperature area.
[0072] The specific implementation process of this embodiment can refer to the aforementioned embodiment of determining the first compensation coefficient of the spatial gain, and will not be repeated here.
[0073] The above embodiment divides the image into multiple sub-regions and calculates the first compensation coefficient for spatial gain and the second compensation coefficient for preference gain in segments. This allows for differentiated calculation of the compensation coefficients within the same color temperature region based on the differences in AWB coordinates, and uses different compensation coefficients at different AWB coordinates. This reduces color conflicts caused by different AWB coordinates within the same color temperature region, better copes with complex lighting (such as mixed light sources), and improves white balance processing.
[0074] S106 , determining a white balance gain for each sub-region based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-region.
[0075] S108 , performing white balance correction on the sub-regions according to the white balance gain of each sub-region.
[0076] For step S106, this embodiment may include: obtaining the statistical gain, first spatial gain and first preference gain of each sub-area; and determining the white balance gain of each sub-area based on the statistical gain, first spatial gain and first compensation coefficient, first preference gain and second compensation coefficient of each sub-area.
[0077] Specifically, in this embodiment, a preset algorithm may be used to determine the white balance gain of the sub-region according to the statistical gain, the first spatial gain and the first compensation coefficient, the first preference gain and the second compensation coefficient. The preset algorithm may include the following formula:
[0078] AWB_gain=(sta_gain*prob+spa_gain*spa_gain_ratio*(1
[0079] -prob))*(pref_gain*pref_gain_ratio)
[0080] Among them, AWB_gain represents the white balance gain of the sub-area, sta_gain represents the statistical gain, prob represents the proportion of the statistical gain, spa_gain represents the first spatial gain, spa_gain_ratio represents the first compensation coefficient, pref_gain represents the first preference gain, and pref_gain_ratio represents the second compensation coefficient.
[0081] Refer to the above formula and Figure 3 In this embodiment, for each sub-region, the target statistical gain is first determined based on the statistical gain and the proportion of the statistical gain; the second spatial gain is then determined based on the first spatial gain and the first compensation coefficient; the fusion gain is then determined based on the target statistical gain, the proportion of the statistical gain, and the second spatial gain; and the second preference gain is determined based on the first preference gain and the second compensation coefficient; finally, the product of the second preference gain and the fusion gain is determined as the white balance gain of the sub-region.
[0082] In an example at an AWB coordinate, assuming the statistical gain is 446, the proportion of the statistical gain is 0.76, the first spatial gain is 443, and the first preference gain is 515. If the white balance gain calculated using the existing AWB algorithm is:
[0083] AWB_R_gain=(446*0.76+443*(1-0.76))*(515 / 512)≈448
[0084] In comparison, using the method disclosed herein, the white balance gain calculated after adjusting the compensation coefficient is:
[0085] AWB_R_gain=(446*0.76+443*(521 / 512)*(1-0.76))*(443*(521 / 512)≈458.
[0086] In another example at AWB coordinates, assuming the statistical gain is 502, the proportion of the statistical gain is 0.76, the first spatial gain is 443, and the first preference gain is 504. If the white balance gain calculated using the existing AWB algorithm is:
[0087] AWB_R_gain:(502*0.76+443*(1-0.76))*(504 / 512)≈491
[0088] In comparison, using the method disclosed herein, the white balance gain calculated after adjusting the compensation coefficient is:
[0089] AWB_R_gain=(502*0.76+443*(504 / 512)*(1-0.76))*(504*(504 / 512)≈482
[0090] The calculated values from the two examples above demonstrate that the white balance gains of the R channel at different AWB coordinates in the processed image can be modified in the desired directions without affecting each other. This allows different white balance gains to be used at different AWB coordinates within the same color temperature region, thereby reducing color clashes within the same color temperature region at different AWB coordinates. It should be understood that the white balance gains for the G and B channels are determined in the same way as for the R channel; the R channel is used as an example for this explanation.
[0091] In summary, the image processing method provided by the embodiment of the present disclosure includes: dividing the same color temperature area of the image to be processed into multiple sub-areas; for each sub-area, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain; based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-area, determining the white balance gain of each sub-area; and performing white balance correction on the image to be processed according to the white balance gain of each sub-area.
[0092] This technical solution divides the same color temperature area of the image to be processed into multiple sub-areas, so that the first compensation coefficient of the spatial gain and the second compensation coefficient of the preference gain can be calculated in segments. On this basis, the respective white balance gain is determined for each sub-area, so that the compensation coefficients in the same color temperature area are calculated differently according to the differences in the sub-areas. Different compensation coefficients are used in different sub-areas, which is conducive to improving the accuracy of the calculated white balance gain, and can effectively improve the color conflict problem existing in the same color temperature area, which is conducive to more realistic restoration of image colors and improved white balance processing effect.
[0093] Furthermore, the image processing method provided by the embodiment of the present disclosure can adapt to various white balance scenes, including single light source shooting scenes and multi-light source shooting scenes, and has strong scene adaptability.
[0094] In one embodiment, Figure 4 As shown, an image processing device 200 is provided, which includes:
[0095] A region division module 210 is configured to divide the same color temperature region of the image to be processed into multiple sub-regions;
[0096] a compensation coefficient determination module 220, configured to determine, for each of the sub-regions, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain;
[0097] a white balance gain determination module 230, configured to determine a white balance gain for each sub-region based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-region;
[0098] The white balance correction module 240 is configured to perform white balance correction on the image to be processed according to the white balance gain of each sub-region.
[0099] In one embodiment, the compensation coefficient determination module 220 further includes:
[0100] a node determining unit, configured to determine, for each of the sub-regions, an average AWB coordinate of the sub-region as a node for adjusting a compensation coefficient;
[0101] A coefficient determination unit is used to determine, for each of the nodes, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain according to the AWB parameter of the node.
[0102] In one embodiment, the coefficient determination unit is further configured to:
[0103] Obtaining AWB parameters of the node; wherein the AWB parameters include original spatial gain and original preference gain;
[0104] determining a first compensation coefficient of the spatial gain based on a ratio between the original spatial gain and a preset basic parameter;
[0105] A second compensation coefficient of the preference gain is determined based on a ratio between the original preference gain and the basic parameter.
[0106] In one embodiment, the coefficient determination unit is further configured to:
[0107] Determining a ratio between the original spatial gain and a preset basic parameter as a key compensation coefficient of the spatial gain at the node;
[0108] An interpolation calculation is performed between the key compensation coefficients of the spatial gain corresponding to every two adjacent nodes to obtain a first compensation coefficient of the spatial gain corresponding to each AWB coordinate in the color temperature area.
[0109] In one embodiment, the white balance gain determination module 230 is further configured to:
[0110] Obtaining a statistical gain, a first spatial gain, and a first preference gain for each of the sub-regions;
[0111] A white balance gain of each of the sub-regions is determined based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each of the sub-regions.
[0112] In one embodiment, the white balance gain determination module 230 is further configured to:
[0113] For each of the sub-regions, determining a target statistical gain according to the statistical gain and the proportion of the statistical gain;
[0114] determining a second spatial gain according to the first spatial gain and the first compensation coefficient;
[0115] Determining a fusion gain based on the target statistical gain, the proportion of the statistical gain, and the second spatial gain;
[0116] determining a second preference gain according to the first preference gain and the second compensation coefficient;
[0117] The product of the second preference gain and the fusion gain is determined as the white balance gain of the sub-region.
[0118] In one embodiment, the white balance gain determination module 230 is further configured to:
[0119] Determining the white balance gain of the sub-region by a preset algorithm and based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient; wherein the preset algorithm includes:
[0120] AWB_gain=(sta_gain*prob+spa_gain*spa_gain_ratio*(1-prob))*(pre f_gain*pref_gain_ratio)
[0121] Among them, AWB_gain represents the white balance gain of the sub-area, sta_gain represents the statistical gain, prob represents the proportion of the statistical gain, spa_gain represents the first spatial gain, spa_gain_ratio represents the first compensation coefficient, pref_gain represents the first preference gain, and pref_gain_ratio represents the second compensation coefficient.
[0122] In the above-mentioned image processing device, by dividing the same color temperature area of the image to be processed into multiple sub-areas, the first compensation coefficient of the spatial gain and the second compensation coefficient of the preference gain can be calculated in segments. On this basis, the respective white balance gain is determined for each sub-area, so that the compensation coefficients in the same color temperature area are calculated differently according to the differences in the sub-areas. Using different compensation coefficients in different sub-areas is conducive to improving the accuracy of the calculated white balance gain, and thus can effectively improve the color conflict problem existing in the same color temperature area, which is conducive to more realistic restoration of image colors and improving the white balance processing effect.
[0123] For the specific definition of the image processing device, please refer to the definition of the image processing method above and will not be repeated here. Each module in the above-mentioned image processing device can be implemented in whole or in part through software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each of the above modules.
[0124] In one embodiment, an electronic device is provided. The electronic device may be a terminal, and its internal structure diagram may be as follows: Figure 5As shown. The electronic device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the electronic device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, an image processing method is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the electronic device housing, or an external keyboard, touchpad or mouse.
[0125] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0126] In one embodiment, the image processing apparatus provided by the present application can be implemented in the form of a computer program. The computer program can be used in Figure 5 The memory of the electronic device may store various program modules constituting the image processing device, such as: Figure 4 The area division module 210, compensation coefficient determination module 220, white balance gain determination module 230 and white balance correction module 240 are shown. The computer program composed of various program modules enables the processor to execute the steps of the image processing method of each embodiment of the present application described in this specification.
[0127] For example, Figure 5 The electronic device shown can be Figure 4The area division module 210 in the device shown is used to divide the same color temperature area of the image to be processed into multiple sub-areas; the electronic device can use the compensation coefficient determination module 220 to determine, for each of the sub-areas, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain; the electronic device can use the white balance gain determination module 230 to determine the white balance gain of each sub-area based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-area; the electronic device can use the white balance correction module 240 to perform white balance correction on the image to be processed according to the white balance gain of each sub-area.
[0128] In one embodiment, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented: dividing a same color temperature region of an image to be processed into a plurality of sub-regions;
[0129] For each of the sub-regions, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain;
[0130] determining a white balance gain for each of the sub-regions based on the first compensation coefficient and the second compensation coefficient corresponding to each of the sub-regions;
[0131] White balance correction is performed on the image to be processed according to the white balance gain of each sub-region.
[0132] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0133] Optionally, determining, for each of the sub-regions, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain includes:
[0134] For each of the sub-regions, determining an average AWB coordinate of the sub-region as a node for adjusting a compensation coefficient;
[0135] For each of the nodes, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain are determined according to the AWB parameter of the node.
[0136] Optionally, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain according to the AWB parameter of the node includes:
[0137] Obtaining AWB parameters of the node; wherein the AWB parameters include original spatial gain and original preference gain;
[0138] determining a first compensation coefficient of the spatial gain based on a ratio between the original spatial gain and a preset basic parameter;
[0139] A second compensation coefficient of the preference gain is determined based on a ratio between the original preference gain and the basic parameter.
[0140] Optionally, determining a first compensation coefficient of the spatial gain based on a ratio between the original spatial gain and a preset basic parameter includes:
[0141] Determining a ratio between the original spatial gain and a preset basic parameter as a key compensation coefficient of the spatial gain at the node;
[0142] An interpolation calculation is performed between the key compensation coefficients of the spatial gain corresponding to every two adjacent nodes to obtain a first compensation coefficient of the spatial gain corresponding to each AWB coordinate in the color temperature area.
[0143] Optionally, determining the white balance gain of each sub-region based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-region includes:
[0144] Obtaining a statistical gain, a first spatial gain, and a first preference gain for each of the sub-regions;
[0145] A white balance gain of each of the sub-regions is determined based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each of the sub-regions.
[0146] Optionally, determining the white balance gain of each sub-region based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each sub-region includes:
[0147] For each of the sub-regions, determining a target statistical gain according to the statistical gain and the proportion of the statistical gain;
[0148] determining a second spatial gain according to the first spatial gain and the first compensation coefficient;
[0149] Determining a fusion gain based on the target statistical gain, the proportion of the statistical gain, and the second spatial gain;
[0150] determining a second preference gain according to the first preference gain and the second compensation coefficient;
[0151] The product of the second preference gain and the fusion gain is determined as the white balance gain of the sub-region.
[0152] Optionally, determining the white balance gain of each sub-region based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each sub-region includes:
[0153] Determining the white balance gain of the sub-region by a preset algorithm and based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient; wherein the preset algorithm includes:
[0154] AWB_gain=(sta_gain*prob+spa_gain*spa_gain_ratio*(1-prob))*(pre f_gain*pref_gain_ratio)
[0155] Among them, AWB_gain represents the white balance gain of the sub-area, sta_gain represents the statistical gain, prob represents the proportion of the statistical gain, spa_gain represents the first spatial gain, spa_gain_ratio represents the first compensation coefficient, pref_gain represents the first preference gain, and pref_gain_ratio represents the second compensation coefficient.
[0156] In the above-mentioned electronic device, by dividing the same color temperature area of the image to be processed into multiple sub-areas, the first compensation coefficient of the spatial gain and the second compensation coefficient of the preference gain can be calculated in segments. On this basis, the respective white balance gain is determined for each sub-area, so that the compensation coefficients in the same color temperature area are calculated differently according to the differences in the sub-areas. Using different compensation coefficients in different sub-areas is conducive to improving the accuracy of the calculated white balance gain, and thus can effectively improve the color conflict problem existing in the same color temperature area, which is conducive to more realistic restoration of image colors and improved white balance processing effect.
[0157] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: dividing a same color temperature region of an image to be processed into a plurality of sub-regions;
[0158] For each of the sub-regions, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain;
[0159] determining a white balance gain for each of the sub-regions based on the first compensation coefficient and the second compensation coefficient corresponding to each of the sub-regions;
[0160] White balance correction is performed on the image to be processed according to the white balance gain of each sub-region.
[0161] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0162] Optionally, determining, for each of the sub-regions, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain includes:
[0163] For each of the sub-regions, determining an average AWB coordinate of the sub-region as a node for adjusting a compensation coefficient;
[0164] For each of the nodes, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain are determined according to the AWB parameter of the node.
[0165] Optionally, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain according to the AWB parameter of the node includes:
[0166] Obtaining AWB parameters of the node; wherein the AWB parameters include original spatial gain and original preference gain;
[0167] determining a first compensation coefficient of the spatial gain based on a ratio between the original spatial gain and a preset basic parameter;
[0168] A second compensation coefficient of the preference gain is determined based on a ratio between the original preference gain and the basic parameter.
[0169] Optionally, determining a first compensation coefficient of the spatial gain based on a ratio between the original spatial gain and a preset basic parameter includes:
[0170] Determining a ratio between the original spatial gain and a preset basic parameter as a key compensation coefficient of the spatial gain at the node;
[0171] An interpolation calculation is performed between the key compensation coefficients of the spatial gain corresponding to every two adjacent nodes to obtain a first compensation coefficient of the spatial gain corresponding to each AWB coordinate in the color temperature area.
[0172] Optionally, determining the white balance gain of each sub-region based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-region includes:
[0173] Obtaining a statistical gain, a first spatial gain, and a first preference gain for each of the sub-regions;
[0174] A white balance gain of each of the sub-regions is determined based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each of the sub-regions.
[0175] Optionally, determining the white balance gain of each sub-region based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each sub-region includes:
[0176] For each of the sub-regions, determining a target statistical gain according to the statistical gain and the proportion of the statistical gain;
[0177] determining a second spatial gain according to the first spatial gain and the first compensation coefficient;
[0178] Determining a fusion gain based on the target statistical gain, the proportion of the statistical gain, and the second spatial gain;
[0179] determining a second preference gain according to the first preference gain and the second compensation coefficient;
[0180] The product of the second preference gain and the fusion gain is determined as the white balance gain of the sub-region.
[0181] Optionally, determining the white balance gain of each sub-region based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each sub-region includes:
[0182] Determining the white balance gain of the sub-region by a preset algorithm and based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient; wherein the preset algorithm includes:
[0183] AWB_gain=(sta_gain*prob+spa_gain*spa_gain_ratio*(1-prob))*(pre f_gain*pref_gain_ratio)
[0184] Among them, AWB_gain represents the white balance gain of the sub-area, sta_gain represents the statistical gain, prob represents the proportion of the statistical gain, spa_gain represents the first spatial gain, spa_gain_ratio represents the first compensation coefficient, pref_gain represents the first preference gain, and pref_gain_ratio represents the second compensation coefficient.
[0185] In the above-mentioned storable medium, the same color temperature area of the image to be processed can be divided into multiple sub-areas, so that the first compensation coefficient of the spatial gain and the second compensation coefficient of the preference gain can be calculated in segments. On this basis, the respective white balance gain is determined for each sub-area, so that the compensation coefficients in the same color temperature area are calculated differently according to the differences in the sub-areas. Using different compensation coefficients in different sub-areas is conducive to improving the accuracy of the calculated white balance gain, and thus can effectively improve the color conflict problem existing in the same color temperature area, which is conducive to more realistic restoration of image colors and improving the white balance processing effect.
[0186] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static random access memory (SRAM) and dynamic random access memory (DRAM).
[0187] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0188] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. An image processing method, characterized in that: The method comprises: Divide the same color temperature area of the image to be processed into multiple sub-areas; For each of the sub-regions, determining a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain; determining a white balance gain for each of the sub-regions based on the first compensation coefficient and the second compensation coefficient corresponding to each of the sub-regions; White balance correction is performed on the image to be processed according to the white balance gain of each sub-region.
2. The method according to claim 1, characterized in that The determining, for each of the sub-regions, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain includes: For each of the sub-regions, determining an average AWB coordinate of the sub-region as a node for adjusting a compensation coefficient; For each of the nodes, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain are determined according to the AWB parameter of the node.
3. The method according to claim 2, characterized in that The determining, according to the AWB parameter of the node, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain includes: Obtaining AWB parameters of the node; wherein the AWB parameters include original spatial gain and original preference gain; determining a first compensation coefficient of the spatial gain based on a ratio between the original spatial gain and a preset basic parameter; A second compensation coefficient of the preference gain is determined based on a ratio between the original preference gain and the basic parameter.
4. The method according to claim 3, characterized in that The determining, based on a ratio between the original spatial gain and a preset basic parameter, a first compensation coefficient of the spatial gain includes: Determining a ratio between the original spatial gain and a preset basic parameter as a key compensation coefficient of the spatial gain at the node; An interpolation calculation is performed between the key compensation coefficients of the spatial gain corresponding to every two adjacent nodes to obtain a first compensation coefficient of the spatial gain corresponding to each AWB coordinate in the color temperature area.
5. The method according to claim 1, wherein The determining the white balance gain of each sub-region based on the first compensation coefficient and the second compensation coefficient corresponding to each sub-region includes: Obtaining a statistical gain, a first spatial gain, and a first preference gain for each of the sub-regions; A white balance gain of each of the sub-regions is determined based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each of the sub-regions.
6. The method according to claim 5, characterized in that The determining the white balance gain of each sub-region based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each sub-region includes: For each of the sub-regions, determining a target statistical gain according to the statistical gain and the proportion of the statistical gain; determining a second spatial gain according to the first spatial gain and the first compensation coefficient; Determining a fusion gain based on the target statistical gain, the proportion of the statistical gain, and the second spatial gain; determining a second preference gain according to the first preference gain and the second compensation coefficient; The product of the second preference gain and the fusion gain is determined as the white balance gain of the sub-region.
7. The method according to claim 5, characterized in that The determining the white balance gain of each sub-region based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient of each sub-region includes: Determining the white balance gain of the sub-region by a preset algorithm and based on the statistical gain, the first spatial gain, the first compensation coefficient, the first preference gain, and the second compensation coefficient; wherein the preset algorithm includes: AWB_gain=(sta_gain*prob+spa_gain*spa_gain_ratio*(1-prob))*(pre f_gain*pref_gain_ratio) Among them, AWB_gain represents the white balance gain of the sub-area, sta_gain represents the statistical gain, prob represents the proportion of the statistical gain, spa_gain represents the first spatial gain, spa_gain_ratio represents the first compensation coefficient, pref_gain represents the first preference gain, and pref_gain_ratio represents the second compensation coefficient.
8. An image processing device, characterized in that: The device comprises: A region division module is used to divide the same color temperature region of the image to be processed into multiple sub-regions; a compensation coefficient determination module, configured to determine, for each of the sub-regions, a first compensation coefficient corresponding to the spatial gain and a second compensation coefficient corresponding to the preference gain; a white balance gain determination module, configured to determine a white balance gain for each of the sub-regions based on the first compensation coefficient and the second compensation coefficient corresponding to each of the sub-regions; The white balance correction module is configured to perform white balance correction on the image to be processed according to the white balance gain of each sub-region.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.