Image processing method and device, electronic equipment and computer storage medium
By performing color gain compensation and gradient calculation on the first image, the second color gain is determined, and the problem of local color casting in the image product is solved, reducing the calculation amount and improving the image quality.
Patent Information
- Application Number
- CN202510105591.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-05-06
AI Technical Summary
In the field of image products, the camera module has a high light intensity in the center of the image sensor than the edge due to the convex lens, and local color casting occurs in the image. The existing adaptive correction algorithm has a large amount of calculation and poor effect.
By acquiring the first image and the second image, the second image is obtained by compensating the first image with the first color gain, and based on the gradient calculation of the first color distribution image of the second image, a second color distribution image is obtained, and the second color gain is determined based on the first color distribution image and the second color distribution image, and the first image is compensated based on the first color gain and the second color gain to obtain an output image.
The calculation amount of color gain compensation for the image is reduced, while improving the problem of local color casting of the image and improving the image quality.
Smart Images

Figure CN119946447A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to image processing technology, and in particular to an image processing method, device, electronic device and computer storage medium. Background Art
[0002] In the field of imaging products, due to the focusing effect of the convex lens of the camera module, the light intensity in the center of the image sensor is greater than that at the edge, and the three color channels of red, green and blue (RGB) obtained by the sensor during imaging are unevenly distributed in different areas of the image, and there are deviations, resulting in local color cast of the image.
[0003] In order to eliminate the deviation in the above image, an adaptive correction algorithm can be used. However, the algorithm has a large amount of calculation, resulting in a long calculation time and poor image correction effect. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, device, electronic device and computer storage medium, which can improve the local color cast of an image to improve the image quality.
[0005] The technical solution of this application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides an image processing method, comprising:
[0007] Acquire a first image and a second image; wherein the second image is obtained by compensating the first image using a first color gain; and the first color gain is determined according to scene information of the first image;
[0008] Obtaining a second color distribution image based on a gradient calculation of the first color distribution image of the second image;
[0009] determining a second color gain according to the first color distribution image and the second color distribution image;
[0010] The first image is compensated according to the first color gain and the second color gain to obtain an output image.
[0011] In a second aspect, an embodiment of the present application provides an image processing device, including:
[0012] An acquisition module, used for acquiring a first image and a second image; wherein the second image is obtained by compensating the first image with a first color gain; and the first color gain is determined according to scene information of the first image;
[0013] A calculation module, configured to obtain a second color distribution image based on a gradient calculation of the first color distribution image of the second image;
[0014] a determination module, configured to determine a second color gain according to the first color distribution image and the second color distribution image;
[0015] A compensation module is used to compensate the first image according to the first color gain and the second color gain to obtain an output image.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a storage medium storing instructions executable by the processor; the storage medium relies on the processor to perform operations through a communication bus, and when the instructions are executed by the processor, the image processing method described in one or more of the above embodiments is executed.
[0017] In a fourth aspect, an embodiment of the present application provides a computer storage medium storing executable instructions. When the executable instructions are executed by one or more processors, the processors execute the image processing method described in one or more of the above embodiments.
[0018] The embodiment of the present application provides an image processing method, device, electronic device and computer storage medium, wherein a first image and a second image are obtained, wherein the second image is obtained by compensating the first image with a first color gain, wherein the first color gain is determined according to scene information of the first image, and the second color distribution image is obtained based on the gradient calculation of the first color distribution image of the second image, and the second color gain is determined according to the first color distribution image and the second color distribution image, and the first image is compensated according to the first color gain and the second color gain to obtain an output image; that is, in the embodiment of the present application, the second image is obtained by compensating the first image with color gain, and then the second color distribution image is obtained based on the gradient calculation of the first color distribution image of the second image, thereby determining the second color gain according to the first color distribution image and the second color distribution image, and compensating the first image with the first color gain, thereby outputting an image, thus, compared with the iterative method, the second color gain obtained by the above-mentioned gradient calculation can reduce the amount of calculation in color gain compensation for the first image, and it can be seen that through the above-mentioned compensation method of the first color gain and the second color gain, while reducing the amount of calculation, the influence of uneven color distribution in the original image on the image quality can be improved, thereby improving the problem of local color cast of the image and improving the quality of the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1a is a schematic diagram of an image without color shadow in the related art;
[0020] Figure 1b A schematic diagram of an image with color shadows in the related art;
[0021] Figure 2 A schematic diagram of color deviation distribution of an image with color shadows in the related art;
[0022] Figure 3 A schematic flow chart of an optional image processing method provided in an embodiment of the present application;
[0023] Figure 4 A flowchart of an example of an optional image processing method provided in an embodiment of the present application;
[0024] Figure 5 A schematic diagram of the structure of an optional image processing device provided in an embodiment of the present application;
[0025] Figure 6 A schematic diagram of the structure of an optional electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0027] In the related technology, in the field of imaging products, due to the focusing effect of the convex lens of the camera module, the light intensity at the center of the sensor is greater than that at the edge, and the three color channels of red (R), green (G) and blue (B) obtained by the sensor during imaging are unevenly distributed in different areas of the image, resulting in color deviation and local color cast of the image. This situation is called color shading.
[0028] Figure 1a is a schematic diagram of an image without color shadow in the related art, Figure 1b is a schematic diagram of an image with color shadows in the related art, Figure 1b and Figure 1a In contrast, the color distribution in different areas of the image is uneven.
[0029] Figure 2 Schematic diagram of color deviation distribution of images with color shadows in related art, such as Figure 2 As shown, the horizontal axis is the position on the image, and the vertical axis is the value of the RGB channel. Due to the color shading phenomenon, the pixel values of the R channel and the B channel deviate more from the pixel values of the G channel on both sides of the image, and the pixel values deviate less from the G channel in the middle area of the image.
[0030] Since the proportion of red, green and blue light intensities of light sources with different color temperatures is different, their color shading profiles are also different. In addition, due to the variable light source mixture in real scenes and the colorful colors of photographed objects, it is difficult to achieve a good effect of removing image color shadows by simply calibrating the color shading profile.
[0031] In the field of imaging products, the color shading correction schemes in related technologies are mainly based on algorithms that combine laboratory calibration and adaptive correction. Among them, laboratory calibration is to collect color shading profiles under multiple high, medium and low color temperature light sources in a standard laboratory light box environment, and calculate the color gain map (color gain map) required for the R channel and B channel of color shading compensation. Adaptive correction means that after a certain calibrated color gainmap is applied to the image, there is still residual slight color shading in the image, and it is necessary to automatically correct the remaining color shading by analyzing the color components of the R channel and the color components of the B channel in the actual image.
[0032] However, in the related art, adaptive correction also usually adopts an iterative solution method, which results in a large amount of calculation for compensating the color non-uniformity of the image and a long calculation time.
[0033] In view of the technical problem that there is a large amount of calculation when compensating for color unevenness of an image, an embodiment of the present application provides an image processing method. Figure 3 A flowchart of an optional image processing method provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the image processing method may include:
[0034] S301: Acquire a first image and a second image;
[0035] The first image may be an image obtained from other devices or an image taken by a camera. The embodiment of the present application does not specifically limit this. If the first image is an image taken by a camera, that is, when the electronic device uses any one or more cameras of its own to take an image, the image taken by the camera can be obtained, which is recorded as the first image. The first image may be an RGB image. In order to eliminate the problem of uneven color distribution caused by color shadows, in the embodiment of the present application, after obtaining the first image, the second image is also obtained.
[0036] The second image is obtained by compensating the first image using the first color gain, and the first color gain is determined according to the scene information of the first image. Here, after the first image is acquired, the first color gain is determined according to the scene information of the first image, and the first image is compensated using the first color gain to obtain the second image; wherein the scene information may be ambient light source information, for example, ambient light source color temperature and / or ambient light source intensity.
[0037] Here, it should be noted that the above-mentioned first color gain can generally include: the color gain of the R channel, the color gain of the B channel and the color gain of the G channel, wherein the color gain of the R channel and the color gain of the B channel are determined based on the calibration data, and the color gain of the G channel defaults to 1.
[0038] It can be seen that, through the above S301, the original image captured by the camera and the image obtained by compensating the original image with the calibrated color gain can be obtained.
[0039] S302: Obtaining a second color distribution image based on a gradient calculation of the first color distribution image of the second image;
[0040] After the first image and the second image are obtained through S301, in S302, the color distribution image of the second image is recorded as the first color distribution image, and the gradient calculation is performed on the first color distribution image to obtain the second color distribution. Of course, here, the gradient calculation can be performed on the first color distribution image and then the divergence calculation can be performed to obtain the second color distribution image. Of course, other methods can also be used, such as a neural network model method to calculate the second color distribution image. Here, the embodiment of the present application does not make specific limitations on this.
[0041] Among them, the above-mentioned first color distribution image and the second color distribution image can be the color distribution image of the R channel, or the color distribution image of the B channel, or the color distribution image of the R channel and the color distribution image of the B channel. Here, the embodiment of the present application does not make any specific limitations on this.
[0042] In order to obtain the second color distribution image, taking the color distribution image of the R channel as an example, the color distribution image of the R channel of the second color distribution image is obtained based on the gradient calculation of the color distribution image of the R channel of the first color distribution image. The color distribution image of the B channel is similar to the color distribution image of the R channel, and will not be repeated here.
[0043] S303: determining a second color gain according to the first color distribution image and the second color distribution image;
[0044] After the second color distribution image is obtained through the above S302, in S303, the second color gain is determined according to the first color distribution image and the second color distribution image. Since the second color gain is a color gain for uneven color distribution caused by factors other than color shadows, here, the first color distribution image is an image obtained by compensating the original image with the calibrated first color gain, which is a compensation for the uneven color distribution caused by the color shadow factor. Therefore, the obtained first color distribution image is a color distribution image with the color shadow removed by calibration.
[0045] The second color distribution image is an image obtained on the basis of the color distribution image by removing the color shadow through calibration. As is well known, for an image, in addition to the uneven color distribution caused by the color shadow, there is also uneven color distribution caused by factors other than the color shadow. Here, the second color distribution image is obtained based on the divergence of the first color distribution image, so that the second color distribution image removes the uneven color distribution caused by the color shadow and the uneven color distribution caused by factors other than the color shadow.
[0046] Here, the corresponding second color gain can be determined according to the pixel value of the first color distribution image and the pixel value of the second color distribution image, and the second color gain can also be determined according to the ratio of the pixel value of the first color distribution image and the pixel value of the second color distribution image. Here, the embodiment of the present application does not make any specific limitation on this.
[0047] In this way, the color gain of the uneven color distribution caused by factors other than color shadows can be determined according to the first color distribution image and the second color distribution image, and is recorded as the second color gain.
[0048] S304: Compensate the first image according to the first color gain and the second color gain to obtain an output image, and display the output image.
[0049] After the color gain of the uneven color distribution caused by factors other than color shadows is determined in S303, the first image may be compensated according to the product of the first color gain and the second color gain in S304 to obtain and display an output image.
[0050] It can be seen from the above that the first color gain is a color gain for uneven color distribution caused by color shading, and the second color gain is a color gain for uneven color distribution caused by factors other than color shading.
[0051] Then, in order to eliminate the uneven color distribution caused by color shadows and the uneven color distribution caused by factors other than color shadows, here, the first color gain and the second color gain can be multiplied, and the captured first image can be compensated according to the product, so as to achieve compensation for the color unevenness of the first image caused by the color shadow factor, and achieve compensation for the uneven color distribution caused by factors other than color shadows, thereby eliminating the uneven color distribution caused by the color shadow factor in the first image and the uneven color distribution caused by factors other than color shadows, obtaining an output image, and displaying it on the display screen of the electronic device.
[0052] Further, in order to obtain the first color distribution image, in an optional embodiment, S302 may include:
[0053] Based on the gradient calculation of the first color distribution image of the second image, a gradient of the first color distribution image is obtained;
[0054] Based on the divergence calculation of the gradient of the first color distribution image, a second color distribution image is obtained.
[0055] It can be understood that after obtaining the second image, the first color distribution image of the second image can be determined, wherein, in the color distribution image, the pixel value of the R channel is the pixel value of the R channel of the second image divided by the pixel value of the G channel of the second image, and the pixel value of the B channel is the pixel value of the B channel of the second image divided by the pixel value of the G channel of the second image, so that the first color distribution image can be obtained.
[0056] After the first color distribution is obtained, the gradient of the first color distribution image may be calculated first, and then the divergence of the first color distribution image may be calculated according to the gradient of the first color distribution image.
[0057] For the R channel of the first color distribution image, the gradient of the R channel of the first color distribution image is first determined, and then the divergence of the R channel of the first color distribution image is determined according to the gradient of the R channel of the first color distribution image. For the B channel of the first color distribution image, it is similar to the R channel and will not be described in detail here.
[0058] In this way, by first determining the gradient of the first color distribution image and then determining the divergence of the first color distribution image based on the gradient, the divergence of the first color distribution image can be obtained, which provides a data basis for further determining the second color distribution image.
[0059] In order to obtain the second color distribution image based on the divergence of the first color distribution image, in an optional embodiment, obtaining the second color distribution image based on the divergence calculation of the gradient of the first color distribution image may include:
[0060] Calculating the divergence of the gradient of the first color distribution image to obtain the divergence of the first color distribution image;
[0061] The boundary pixel value of the first color distribution image of the second image is used as a boundary condition, and Fourier transform is performed on the divergence of the first color distribution image to obtain the second color distribution image.
[0062] It can be understood that the above-mentioned first color distribution image and second color distribution image can be the color distribution image of the R channel, or the color distribution image of the B channel, or the color distribution image of the R channel and the color distribution image of the B channel. Here, the embodiment of the present application does not make any specific limitations on this.
[0063] In order to obtain the second color distribution image, taking the color distribution image of the R channel as an example, the boundary pixel value of the color distribution image of the R channel of the first color image is used as the boundary condition, the divergence of the color distribution image of the R channel of the first color distribution image is first determined, and then the divergence of the color distribution image of the R channel of the first color distribution image is Fourier transformed to obtain the color distribution image of the R channel of the second color distribution image. The color distribution image of the B channel is similar to that of the R channel, and will not be repeated here.
[0064] Among them, the boundary pixel values of the above-mentioned first color distribution image are the pixel values distributed at the edge of the image among the pixel values of the first color distribution image. For example, when the first color distribution image is a 3×3 color distribution image, the pixels in the 3×3 pixel values except the pixels at the 2×2 position are called boundary pixel values.
[0065] In this way, by determining the second color distribution image in the manner of Fourier transform, the amount of calculation for determining the second color distribution image can be reduced.
[0066] In order to obtain the divergence of the first color distribution image, in an optional embodiment, obtaining the gradient of the first color distribution image based on the gradient calculation of the first color distribution image of the second image may include:
[0067] According to the first color distribution image, a gradient of the first color distribution image in a preset direction is determined.
[0068] It can be understood that after knowing the first color distribution image, the gradient of the first color distribution image in a preset direction can be determined according to the first color distribution image, wherein the preset direction includes: a preset X direction and a preset Y direction, and the X direction and the Y direction are perpendicular to each other.
[0069] That is to say, the gradient of the first color distribution image in a preset X direction is determined according to the first color distribution image, and the gradient of the first color distribution image in a preset Y direction is determined according to the first color distribution image. For the first color distribution image, the preset X direction is the horizontal coordinate direction on the image, and the preset Y direction is the vertical coordinate direction on the image.
[0070] It can be seen that according to the first color distribution image, the gradient of the R channel of the first color distribution image in the preset X direction, the gradient of the R channel of the first color distribution image in the preset Y direction, the gradient of the B channel of the first color distribution image in the preset X direction, and the gradient of the B channel of the first color distribution image in the preset Y direction can be determined.
[0071] In this way, by determining the gradients of the first color distribution image in the preset X direction and the preset Y direction for the R channel and the B channel respectively, the gradient of the determined first color distribution image can better reflect the color changes of the first color distribution image in different preset directions for different channels, so that the determined second color distribution image eliminates the problem of color unevenness as much as possible.
[0072] Further, in order to determine the gradient of the first color distribution image in a preset direction, in an optional embodiment, determining the gradient of the first color distribution image in the preset direction according to the first color distribution image may include:
[0073] The pixel value of the current block of the first color distribution image is subtracted from the pixel value of the next block of the current block of the first color distribution image along the preset direction to obtain the gradient of the first color distribution image in the preset direction.
[0074] It can be understood that the difference between the pixel value of the current block of the first color distribution image and the pixel value of the next block of the current block of the first color distribution image along the preset direction can be used as the gradient of the first color distribution image in the preset direction.
[0075] For example, the pixel value of the current block of the R channel of the first color distribution image is Img R (i, j), the pixel value of the next block of the current block of the R channel of the first color distribution image along the preset X direction is Img R (i, j+1), the gradient D of the R channel of the first color distribution image in the preset X direction can be calculated using the following formula Rx The gradient D of (i, j) and R channels in the preset Y direction Ry (i, j):
[0076] D Rx (i, j) = Img R (i, j)-Img R (i+1, j) (1)
[0077] D Ry (i, j) = Img R (i, j)-Img R (i, j+1) (2)
[0078] Among them, Img RY (i, j+1) represents the pixel value of the next block of the R channel of the first color distribution image along the preset Y direction. When there is no pixel value of the next block in the preset direction, its gradient is 0.
[0079] Similarly, the gradient of the B channel of the first color distribution image in the preset X direction and the gradient of the B channel in the preset Y direction are determined in a similar manner, which will not be described in detail here.
[0080] In this way, by using the pixel value of the current block minus the pixel value of the next block along the preset direction, the gradient of the first color distribution image in the preset direction is obtained, so that the obtained gradient can reflect the color changes of adjacent pixels in the preset X direction and the preset Y direction for different color channels of the first color distribution image, which helps to further eliminate the problem of color unevenness in the determined second color distribution image as much as possible.
[0081] In order to determine the divergence of the first color distribution image, in an optional embodiment, obtaining the divergence of the first color distribution image based on the divergence calculation of the gradient of the first color distribution image may include:
[0082] The divergence of the first color distribution image in the preset direction is determined according to the gradient of the first color distribution image in the preset direction.
[0083] It can be understood that after knowing the gradient of the first color distribution image, the divergence of the first color distribution image in a preset direction can be determined according to the gradient of the first color distribution image, wherein the preset direction includes: a preset X direction and a preset Y direction, and the X direction and the Y direction are perpendicular to each other.
[0084] That is to say, according to the gradient of the R channel of the first color distribution image in the preset X direction, the divergence of the R channel of the first color distribution image in the preset X direction is determined, and according to the gradient of the R channel of the first color distribution image in the preset Y direction, the divergence of the R channel of the first color distribution image in the preset Y direction is determined. For the first color distribution image, the preset X direction is the horizontal coordinate direction on the image, and the preset Y direction is the vertical coordinate direction on the image.
[0085] It can be seen that according to the first color distribution image, the divergence of the R channel of the first color distribution image in the preset X direction, the divergence of the R channel of the first color distribution image in the preset Y direction, the divergence of the B channel of the first color distribution image in the preset X direction, and the divergence of the B channel of the first color distribution image in the preset Y direction can be determined.
[0086] In this way, by determining the divergence of the first color distribution image in the preset X direction and the preset Y direction for the R channel and the B channel respectively, the divergence of the determined first color distribution image can better reflect how the color changes in the first color distribution image change, so that the determined second color distribution image eliminates the problem of color unevenness as much as possible.
[0087] In addition, in order to determine the divergence of the first color distribution image in a preset direction, in an optional embodiment, determining the divergence of the first color distribution image in the preset direction according to the gradient of the first color distribution image in the preset direction may include:
[0088] Setting the gradient of the first color distribution image in the preset direction that is less than the gradient threshold in the preset direction to zero, to obtain the actual gradient of the first color distribution image in the preset direction;
[0089] The divergence of the first color distribution image in the preset direction is determined according to the actual gradient of the first color distribution image in the preset direction.
[0090] It can be understood that after determining the gradient of the first color distribution image in the preset direction, since color shading is generally a slight gradual color deviation, the color gradient in the preset X direction and the value in the preset Y direction of the color shading area are generally small, while the color changes in the real world have relatively large color gradient values. A certain color gradient threshold is set to eliminate the color shading area and obtain an ideal gradient image without color shading, which is recorded as the actual gradient of the first color distribution image in the preset direction.
[0091] Here, the gradient of the first color distribution image in the preset direction is compared with the gradient threshold of the preset direction. When the gradient of the first color distribution image in the preset direction is less than the gradient threshold of the preset direction, the gradient of the first color distribution image in the preset direction is set to 0. When the gradient of the first color distribution image in the preset direction is greater than or equal to the gradient threshold of the preset direction, the gradient of the first color distribution image in the preset direction remains unchanged.
[0092] It should be noted that, in the above-mentioned comparison of the gradient of the first color distribution image in the preset direction with the gradient threshold of the preset direction, the gradient of the R channel of the first color distribution image in the preset X direction is compared with the gradient threshold of the R channel in the preset X direction, the gradient of the R channel of the first color distribution image in the preset X direction is compared with the gradient threshold of the R channel in the preset X direction, the gradient of the B channel of the first color distribution image in the preset X direction is compared with the gradient threshold of the B channel in the preset X direction, and the gradient of the B channel of the first color distribution image in the preset X direction is compared with the gradient threshold of the B channel in the preset X direction.
[0093] In this way, the actual gradient of the R channel of the first color distribution image in the preset X direction, the actual gradient of the R channel of the first color distribution image in the preset Y direction, the actual gradient of the B channel of the first color distribution image in the preset X direction, the actual gradient of the B channel of the first color distribution image in the preset Y direction, the actual gradient of the B channel of the first color distribution image in the preset X direction, and the actual gradient of the B channel of the first color distribution image in the preset Y direction can be obtained.
[0094] Then, according to the actual gradient of the first color distribution image in the preset direction, the divergence of the first color distribution image in the preset direction is determined. Here, the divergence of the first color distribution image in the preset direction is mainly obtained by taking partial derivative of the actual gradient.
[0095] In this way, by resetting the gradient of the first color distribution image in the preset direction, the color unevenness caused by color shadows is removed, so that the color unevenness in the obtained first color distribution image is the color unevenness caused by factors other than color shadows, and further the determined second color distribution image eliminates the color unevenness problem as much as possible.
[0096] Further, in order to determine the divergence of the first color distribution image in a preset direction, in an optional embodiment, determining the divergence of the first color distribution image in the preset direction according to the actual gradient of the first color distribution image in the preset direction may include:
[0097] Subtract the actual gradient of the previous block of the current block of the first color distribution image along each preset direction from the actual gradient of the current block of the first color distribution image in each preset direction to obtain the divergence of the first color distribution image in each preset direction;
[0098] The sum of the divergences of the first color distribution image in each preset direction is determined as the divergence of the first color distribution image in the preset direction.
[0099] It can be understood that the actual gradient of the current block of the first color distribution image in the preset direction and the actual gradient of the previous block of the current block of the first color distribution image along the preset direction can be used as the gradient of the first color distribution image in the preset direction.
[0100] For example, the actual gradient of the pixel value of the current block of the R channel of the first color distribution image in the preset X direction is S Rx (i, j), the pixel value of the next block of the current block of the R channel of the first color distribution image along the preset X direction is S Rx (i-1, j), the divergence L of the R channel of the first color distribution image in the preset X direction can be calculated using the following formula: Rx (i, j), the divergence L of the R channel in the preset Y direction Ry (i, j) and the divergence V of the R channel of the first color distribution image R (i, j):
[0101] L Rx (i, j) = S x (i, j)-S x (i, j-1) (3)
[0102] L Ry (i, j) = S y (i, j)-S y (i-1, j) (4)
[0103] V R (i, j) = L Rx (i, j)+L Ry (i,j) (5)
[0104] In the case where there is no pixel value of the previous block in the preset direction, the divergence is 0.
[0105] Similarly, the divergence of the B channel of the first color distribution image in the preset X direction, the divergence of the B channel in the preset Y direction and the divergence of the B channel of the first color distribution image are determined in a similar manner, and are not described in detail here.
[0106] In this way, by calculating the divergence of each preset direction as described above, the divergence of all preset directions can be calculated, so that the divergence of the determined first color distribution image can reflect how the color changes in the first color distribution image change from different preset directions for different channels, and further the determined second color distribution image eliminates the problem of color unevenness as much as possible.
[0107] In order to acquire the first image and the second image, in an optional embodiment, S301 may include:
[0108] Acquire a captured first image and scene information of the first image;
[0109] Determining a first color gain under the scene information according to preset calibration data;
[0110] The first image is compensated by using the first color gain to obtain a second image.
[0111] It can be understood that when the camera of the electronic device captures the first image, the electronic device obtains the first image from the camera and obtains the scene of the first image, wherein the scene information of the first image can be obtained through the sensor on the camera and can also be obtained through other sensors on the electronic device. Here, the embodiment of the present application does not make specific limitations on this.
[0112] After acquiring the first image and the scene information of the first image, the first color gain under the scene information is determined according to the preset calibration data, wherein the calibration data is: the correspondence between the preset scene information and the color gain calibrated under the preset scene information. That is to say, the electronic device pre-stores the correspondence between the preset scene information and the color gain calibrated under the preset scene information, so that after knowing the scene information of the first image, the electronic device can determine the color gain corresponding to the scene information of the first image from the correspondence by searching, and record it as the first color gain; or, when the scene information of the first image cannot be found from the correspondence, the two scene information closest to the scene information of the first image can be found, and the color gains corresponding to the two scene information are used to determine the first color gain by interpolation.
[0113] The scene information may be ambient light source information, and the ambient light source information may be the color temperature of the ambient light source and / or the intensity of the ambient light source.
[0114] Here, it should be noted that, in determining the above calibration data, the preset scene information can be obtained first, the calibration image can be collected under the preset scene information, the calibration image can be gridded, and then the color statistics of each grid can be performed to obtain the average value of the R channel, the average value of the B channel, and the average value of the G channel in each grid, and the ratio of the average value of the R channel to the average value of the G channel is used as the gain of the R channel in the first color gain, the ratio of the average value of the B channel to the average value of the G channel is used as the gain of the B channel in the first color gain, and 1 is used as the gain of the G channel in the first color gain. In this way, the corresponding relationship between the preset scene information and the color gain calibrated under the preset scene information can be obtained.
[0115] After obtaining the first color gain, the first image is compensated using the first color gain, thereby obtaining a second image. In this way, the obtained second image eliminates color unevenness caused by color shadows, provides a second image for determining the second color gain, and helps to determine the second color gain.
[0116] Further, in order to obtain the second image, in an optional embodiment, compensating the first image by using the first color gain to obtain the second image may include:
[0117] Divide the first image into grids according to the size of the first color gain to obtain the first image after grid division;
[0118] The first color gain is used to compensate the first image after grid division to obtain a second image.
[0119] It can be understood that after obtaining the first color gain, since the size of the first color gain is pre-calibrated, it may be the same as or different from the resolution of the first image. Generally, the size of the first color gain is smaller than the resolution of the first image. Therefore, here, the electronic device divides the first image into grids according to the size of the first color gain. For example, the size of the first color gain is M×N, then based on this, the first image is divided into M×N grids, so that the first image of the M×N grids can be obtained.
[0120] The first color gain is then used to compensate the first image after grid division to obtain a second image. Specifically, the color gain of the R channel in the color gain of the i×j-th grid in the first color gain is multiplied by the pixel value of the R channel in the i×j-th grid in the first image. The same is true for the B channel. In this way, the second image can be obtained.
[0121] In this way, the data is calibrated by dividing the grid, and the color unevenness caused by the color shadow is removed by dividing the grid, which can reduce the amount of calculation and improve the problem of color unevenness caused by the color shadow in the first image.
[0122] In order to determine the second color gain, in an optional embodiment, S303 may include:
[0123] The second color gain is determined according to a ratio of a pixel value of the second color distribution image to a pixel value of the first color distribution image.
[0124] It can be understood that in order to determine the second color gain, based on knowing the second color distribution image and the first color distribution image, the second color gain can be determined by the ratio of the pixel value of the second color distribution image to the pixel value of the first color distribution image.
[0125] Specifically, the color gain of the R channel of the second color gain can be determined according to the ratio of the pixel value of the R channel of the second color distribution image to the pixel value of the R channel of the first color distribution image, and the color gain of the B channel of the second color gain can be determined according to the ratio of the pixel value of the B channel of the second color distribution image to the pixel value of the B channel of the first color distribution image.
[0126] In determining the second color gain according to the ratio of the pixel value of the second color distribution image to the pixel value of the first color distribution image, the ratio can be directly used as the second color gain, or the ratio can be adjusted after the ratio is determined to obtain the second color gain. Here, the embodiment of the present application does not make any specific limitation on this.
[0127] In this way, the second color gain is determined by the ratio of the pixel value of the second color distribution image to the pixel value of the first color distribution image. The second color distribution image is a color distribution image with color shadows, and the first color distribution image is a color distribution image without color shadows. The second color gain determined by the ratio between them can further compensate for color unevenness in the image except for color shadows, thereby improving image quality.
[0128] Further, in order to obtain and display the output image, in an optional embodiment, S304 may include:
[0129] determining a target color gain of the first image according to a product of the first color gain and the second color gain;
[0130] The first image is compensated according to the target color gain to obtain an output image.
[0131] It can be understood that after knowing the first color gain and the second color gain, the target gain of the first image can be determined according to the product of the two, and then the first image is compensated according to the target gain to obtain the output image and display it.
[0132] Here, the color gain of the R channel of the first color gain is multiplied by the color gain of the R channel of the second color gain, and the color gain of the R channel of the target color gain is determined according to the product of the color gains of the R channel; the color gain of the B channel of the first color gain is multiplied by the color gain of the B channel of the second color gain, and the color gain of the B channel of the target color gain is determined according to the product of the color gains of the B channel.
[0133] In addition, the color gain of the R channel of the target color gain can be multiplied by the value of the R channel of the first image, and the color gain of the B channel of the target color gain can be multiplied by the value of the B channel of the first image, and the value of the G channel of the first image remains unchanged, so that an output image can be obtained and displayed on the display screen of the electronic device.
[0134] In this way, the first image is compensated by the determined target color gain to obtain an output image and display it, so that the output image can be an image without color unevenness based on the original image, thereby reducing the amount of calculation and improving the problem of color unevenness in the image.
[0135] Further, in order to determine the target color gain, in an optional embodiment, determining the target color gain of the first image according to the product of the first color gain and the second color gain may include:
[0136] The product of the first color gain and the second color gain is determined as the target color gain of the first image.
[0137] It can be understood that after the product of the first color gain and the second color gain is determined, the product here may include the product of the color gain of the R channel and the product of the color gain of the B channel.
[0138] Here, the product of the color gains of the R channel may be directly determined as the color gain of the R channel of the target color gain of the first image, and the product of the color gains of the B channel may be directly determined as the color gain of the B channel of the target color gain of the first image.
[0139] In this way, the target color gain is determined by directly multiplying the first color gain by the second color gain, so that the determined target color gain not only takes into account the color unevenness caused by color shading, but also takes into account the color unevenness caused by factors other than color shading, so that the compensation for color unevenness is more comprehensive and the image processing effect is improved.
[0140] In addition, in order to determine the target color gain, in an optional embodiment, determining the target color gain of the first image according to the product of the first color gain and the second color gain may include:
[0141] Adjusting the second color gain according to the scene information of the first image to obtain an adjusted second color gain;
[0142] The product of the first color gain and the adjusted second color gain is determined as the target color gain of the first image.
[0143] It can be understood that when acquiring the first image, the scene information of the first image can also be acquired. The image information here may include: spectral information, dynamic range, local brightness distribution of pixels and color distribution and other information. Based on the image information, the second color gain can be adjusted. The adjustment here can be to increase or decrease, so as to obtain the adjusted second color gain.
[0144] The product of the first color gain and the adjusted second color gain is used as the target color gain of the first image.
[0145] In this way, by adjusting the second color gain, the target color gain takes the scene information of the first image into consideration, so that the obtained output image can further eliminate the problem of color unevenness in the original image, thereby improving the quality of the output image.
[0146] Regarding the above-mentioned ambient light source information, in an optional embodiment, the scene information may be ambient light source information, and the ambient light source information may include one or more of the following: color temperature of the ambient light source, and intensity of the ambient light source.
[0147] It can be understood that the ambient light source information can be the color temperature of the ambient light source, or the intensity of the ambient light source, and of course, it can also be the color temperature of the ambient light source and the intensity of the ambient light source. Of course, it can also include other ambient light source information. Here, the embodiments of the present application do not make specific limitations on this.
[0148] In this way, calibration data can be obtained based on the color temperature and / or intensity of the ambient light source, and then the first color gain can be determined, so that the influence of the color temperature and / or intensity of the ambient light source can be taken into account in eliminating color unevenness, thereby further improving the problem of color unevenness in the image.
[0149] The following is an example to describe the image processing method described in one or more of the above embodiments.
[0150] In related technologies, adaptive color shading correction algorithms are mostly iterative solutions, which have large computational complexity, long calculation time, slow convergence of results, and poor correction effects under complex light sources. This affects the user experience and image quality to a certain extent for mobile product applications.
[0151] This example proposes an adaptive color shading correction algorithm based on laboratory calibration and Poisson equation image fusion. The color shading contours under various light sources are calibrated in the laboratory, and the color gain map that is closer to the actual color shading contour is selected in combination with the actual scene color temperature and applied to the image. Then, the gradient change characteristics of color shading are combined with the Poisson image fusion method to infer the ideal image without residual color shading color shading color shading, and the residual color gain map that eliminates the residual color shading color shading color shading is obtained by combining it with the calibrated color gain map to obtain a good image color shading correction and elimination effect.
[0152] Figure 4 A flowchart of an example of an optional image processing method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the method may include:
[0153] S401: data calibration;
[0154] Specifically, the color shading contours are calibrated under the laboratory's high, medium and low color temperature light sources, and the color gain map is calculated. Under the laboratory's standard light box environment, uniform white field images (equivalent to the above calibration images) are collected under each of the high, medium and low color temperature light sources, and the white field images are divided into M×N grids. The RGB pixel mean values in the grid are statistically calculated by channel, and the R and B mean values are divided by the G mean value to obtain the color statistical distribution information of the red and blue color stats. The calculation formula is as follows:
[0155]
[0156] Among them, colorR(i, j) represents the value of the R channel of the i×jth grid in the calibration image, R mean (i, j) represents the average pixel value of the R channel in the first i×j grid in the calibration image, G mean (i, j) represents the average pixel value of the G channel in the first i×j grid in the calibration image, B mean (i, j) represents the average pixel value of the B channel of the first i×j grid in the calibration image. color B(i, j) represents the value of the B channel of the first i×j grid in the calibration image.
[0157] Taking the center of the color stats grid as the reference, calculate the color gain required when the red and blue colors of the remaining grid statistical points are compensated to the grid center color, thereby forming a color gain map (equivalent to the color gain calibrated above):
[0158]
[0159] Among them, colorR(i center , j center ) represents the color gain of the R channel of the i×jth grid, color B(i center , j center ) represents the color gain of the B channel of the i×jth grid, colorR(i center , j center ) represents the value of the R channel of the i×jth grid in the calibration image, color B(i center , j center ) represents the value of the B channel of the i×j-th grid in the calibration image, and color G(i, j) represents the value of the G channel of the i×j-th grid in the calibration image.
[0160] S402: Compensating the original image using the calibrated data;
[0161] According to the predicted color temperature value ct in the actual scene, the gain maps corresponding to the two adjacent calibrated color temperatures ct1 and ct2 are selected for interpolation to obtain a base color gain map, which is applied to the original image (originImg) to obtain the first compensated image appliedImg.
[0162]
[0163] base gainB ct (i,j)=(ct2-ct) / (ct2-ct1)*gainB ct1 (i,j)+(ct2-ct) / (ct2-ct1)*gainB ct2 (i,j) (11)
[0164] applied Img R (i, j) = originImg R (i, j)*base gainR ct (i, j) (12)
[0165] applied Img B (i, j) = originImg B(i, j)*base gainB ct (i,j) (13)
[0166] Among them, base gainR ct1 (i, j) represents the color gain of the R channel calibrated under ct1, base gainR ct2 (i, j) represents the color gain of the R channel calibrated under ct2, base gainB ct1 (i, j) represents the color gain of the B channel calibrated under ct1, base gainB ct2 (i, j) represents the color gain of the B channel calibrated under ct2, basegainR ct (i, j) represents the color gain of the R channel in the first color gain of the original image, base gainB ct (i, j) represents the color gain of the B channel in the first color gain of the original image, originImg R (i, j) represents the value of the R channel of the i×jth grid of the original originImg, B (i, j) represents the value of the B channel of the i×jth grid of the original originImg, applied Img R (i, j) represents the value of the R channel of the i×jth grid of appliedImg, aμplied Img B (i, j) represents the value of the B channel of the i×j-th grid of appliedImg.
[0167] S403: Determine the gradient image S;
[0168] Take appliedImg as input, divide the red and blue channels by the green channel respectively, calculate the color distribution images ImgR and ImgB, and calculate the color gradients Dx and Dy in the horizontal X direction and vertical Y direction respectively;
[0169]
[0170] D x (i,j)=Img(i,j)-Img(i+1,j) (16)
[0171] D y (i,j)=Img(i,j)-Img(i,j+1) (17)
[0172] Among them, Img R (i, j) represents the value of the R channel of the i×jth grid of ImgR, B(i, j) represents the value of the B channel of the i×jth grid of ImgR, origin Img G (i, j) represents the value of the G channel of the i×jth grid of the original image, D x (i, j) represents the gradient in the X direction, D y (i, j) represents the gradient in the Y direction, Img(i, j) represents the value of the i×j-th grid of ImgR and ImgB, Img(i+1, j) represents the value of the (i+1)×j-th grid of ImgR and ImgB, and Img(i, j+1) represents the value of the i×(j+1)-th grid of ImgR and ImgB.
[0173] It should be noted that when calculating the gradient, if the current block does not have a next block, the gradient of the current block is 0.
[0174] Since color shading is generally a slight gradient color deviation, the color gradient Dx and Dy values of the color shading area are generally small. However, the color changes in the real world have relatively large color gradient Dx and Dy values. A certain color gradient threshold D_threshold is set to remove the color shading area and obtain an ideal gradient image S without color shading:
[0175]
[0176] Among them, S x (i, j) represents the gradient of the i×j grid in the X direction, represents the gradient threshold of the i×j grid in the X direction, S y (i, j) represents the gradient of the i×j grid in the Y direction, Represents the gradient threshold of the i×j grids in the Y direction.
[0177] S404: Determine a divergence image V;
[0178] Based on the ideal gradient image S without color shading, the partial derivative L of its gradient is calculated again, and the divergence value is obtained by adding the partial derivatives in the X direction and the Y direction, thereby obtaining the divergence image V of the entire image:
[0179] L x (i, j) = S x (i, j)-S x (i-1, j) (20)
[0180] L y (i, j) = S y (i, j)-S y (i, j-1) (21)
[0181] V(i, j) = L x (i, j)+L y (i,j) (22)
[0182] Among them, L x (i, j) represents the divergence of the i×jth grid in the X direction, L y (i, j) represents the divergence of the i×j grid in the Y direction, V(i, j) represents the divergence of the i×j grid,
[0183] It should be noted that when calculating the divergence, if the current block does not have a previous block, the divergence of the current block is 0.
[0184] S405: Compensate the original image.
[0185] Based on the divergence image V value, a matrix equation group of Ax=V is constructed, where A is the coefficient of each pixel point in the image gradient solution and divergence solution process, x is the pixel value of the image to be solved, and V is the divergence image result V value. If the general Gaussian elimination method or iterative method is used, a huge number of matrix equation groups need to be constructed, the calculation amount is huge, and it takes a long time.
[0186] In this example, the matrix equation group Ax=V is actually constructed as the Poisson equation. The colors R and B of the boundary pixel values of the image are used as the Dirichlet boundary conditions of the Poisson equation. The divergence image is transformed by fast Fourier transform (FFT). The FFT method can be used to quickly solve the Poisson equation and obtain the ideal image T without color shading.
[0187] Divide the obtained ideal color-free image T of size M×N by appliedImg to obtain the residual color gain map of the adaptive correction process, and multiply it with the calibrated base colorgain map to obtain the complete color shading correction gain map.
[0188]
[0189] final color gain R (i, j) = base color gain R(i,j) *residual color gain R (i,j) (25)
[0190] final color gain B(i, j) = base color gain B(i,j) *residual color gain B (i,j) (26)
[0191] Among them, residual color gain R (i, j) represents the color gain of the R channel determined based on the scatter image, and the residual color gain B (i, j) represents the color gain of the B channel determined based on the scatter image, T R (i, j) represents the value of the R channel of the i×jth grid of image T, T B (i, j) represents the value of the B channel of the i×jth grid of image T, and the final color gain R (i, j) represents the color gain of the R channel of the target color gain of the original image, B (i, j) represents the color gain of the B channel of the target color gain of the original image.
[0192] In this example, based on the differences in color shading contours under different light sources, a linear regression algorithm is used to derive the residual color gain by using information such as color temperature, ambient spectrum information, ambient light intensity, ambient dynamic range, local pixel brightness distribution, and color distribution. R (i, j) and / or residual color gain B (i, j) are adjusted to predict a better color shading profile.
[0193] It can be seen that this example proposes a color shading compensation scheme based on light source calibration and adaptive correction, which can obtain pure images without color shading in complex scenes such as mixed light sources. According to the characteristic that the color shading of the image changes smoothly, the image gradient reconstruction method is adopted, and the Poisson equation and FFT solution mechanism are used to realize the rapid solution of adaptive color shading compensation, thereby reducing the algorithm calculation amount and calculation time.
[0194] This example adopts the color shading compensation method of light source calibration and adaptive correction. On the basis of achieving good color shading correction effect, Poisson image reconstruction and Poisson equation solution methods are introduced to improve the adaptive correction algorithm, reduce the amount of calculation and calculation time, and improve the algorithm operation efficiency.
[0195] An embodiment of the present application provides an image processing method, which obtains a second image by compensating the color gain of a first image, and then obtains the second color distribution image based on the gradient calculation of the first color distribution image of the second image, thereby determining the second color gain according to the first color distribution image and the second color distribution image, and using the second color gain and the first color gain to compensate the first image, thereby outputting an image. In this way, compared with the iterative method, the second color gain obtained by the above-mentioned gradient calculation can reduce the amount of calculation in the color gain compensation of the first image. It can be seen that through the above-mentioned compensation method of the first color gain and the second color gain, it is possible to reduce the amount of calculation while improving the influence of the uneven color distribution in the original image on the image quality, thereby improving the problem of local color cast of the image and improving the image quality.
[0196] Based on the same inventive concept as the above-mentioned embodiment, the embodiment of the present application provides an image processing device, Figure 5 A schematic diagram of the structure of an optional image processing device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the image processing device includes: an acquisition module 51, a calculation module 52, a determination module 53 and a compensation module 54; wherein,
[0197] An acquisition module 51 is used to acquire a first image and a second image; wherein the second image is obtained by compensating the first image using a first color gain; and the first color gain is determined according to scene information of the first image;
[0198] A calculation block 52, configured to calculate the gradient of the first color distribution image based on the second image to obtain a second color distribution image;
[0199] A determination module 53, configured to determine a second color gain according to the first color distribution image and the second color distribution image;
[0200] The compensation module 54 is used to compensate the first image according to the first color gain and the second color gain to obtain an output image.
[0201] In an optional embodiment, the calculation module 52 is specifically used to: calculate the gradient of the first color distribution image based on the gradient of the first color distribution image of the second image to obtain the gradient of the first color distribution image; calculate the divergence of the gradient of the first color distribution image to obtain the second color distribution image.
[0202] In an optional embodiment, the calculation module 52 obtains the second color distribution image based on the divergence calculation of the gradient of the first color distribution image, including: obtaining the divergence of the first color distribution image based on the divergence calculation of the gradient of the first color distribution image; performing Fourier transform on the divergence of the first color distribution image with the boundary pixel value of the first color distribution image of the second image as the boundary condition to obtain the second color distribution image.
[0203] In an optional embodiment, the calculation module 52 obtains the gradient of the first color distribution image based on the gradient calculation of the first color distribution image of the second image, including: determining the gradient of the first color distribution image in a preset direction according to the first color distribution image; wherein the preset direction includes: a preset X direction and a preset Y direction, and the X direction and the Y direction are perpendicular to each other.
[0204] In an optional embodiment, the calculation module 52 determines the gradient of the first color distribution image in a preset direction based on the first color distribution image, including: subtracting the pixel value of the current block of the first color distribution image from the pixel value of the next block of the current block of the first color distribution image along the preset direction to obtain the gradient of the first color distribution image in the preset direction.
[0205] In an optional embodiment, the calculation module 52 calculates the divergence of the first color distribution image based on the divergence of the gradient of the first color distribution image, including: determining the divergence of the first color distribution image in a preset direction according to the gradient of the first color distribution image in the preset direction; wherein the preset direction includes: a preset X direction and a preset Y direction, and the X direction and the Y direction are perpendicular to each other.
[0206] In an optional embodiment, the calculation module 52 determines the divergence of the first color distribution image in the preset direction based on the gradient of the first color distribution image in the preset direction, including: setting the gradient of the first color distribution image in the preset direction that is less than the gradient threshold of the preset direction to zero, so as to obtain the actual gradient of the first color distribution image in the preset direction; and determining the divergence of the first color distribution image in the preset direction based on the actual gradient of the first color distribution image in the preset direction.
[0207] In an optional embodiment, the calculation module 52 determines the divergence of the first color distribution image in the preset direction according to the actual gradient of the first color distribution image in the preset direction, including: subtracting the actual gradient of the previous block of the current block of the first color distribution image along each preset direction from the actual gradient of the current block of the first color distribution image in each preset direction to obtain the divergence of the first color distribution image in each preset direction; and determining the sum of the divergence of the first color distribution image in each preset direction as the divergence of the first color distribution image in the preset direction.
[0208] In an optional embodiment, the acquisition module 51 is specifically used to: acquire a captured first image and scene information of the first image; determine a first color gain under the scene information according to preset calibration data; wherein the calibration data is: a correspondence between the preset scene information and the color gain calibrated under the preset scene information; and use the first color gain to compensate the first image to obtain a second image.
[0209] In an optional embodiment, the acquisition module 51 uses the first color gain to compensate the first image to obtain the second image, including: gridding the first image according to the size of the first color gain to obtain the gridded first image; and compensating the gridded first image using the first color gain to obtain the second image.
[0210] In an optional embodiment, the determination module 53 is specifically configured to determine the second color gain according to a ratio of a pixel value of the second color distribution image to a pixel value of the first color distribution image.
[0211] In an optional embodiment, the compensation module 54 is specifically configured to: determine a target color gain of the first image according to a product of the first color gain and the second color gain; and compensate the first image according to the target color gain to obtain an output image.
[0212] In an optional embodiment, the compensation module 54 determines the target color gain of the first image according to the product of the first color gain and the second color gain, including: determining the product of the first color gain and the second color gain as the target color gain of the first image.
[0213] In an optional embodiment, the compensation module 54 determines the target color gain of the first image according to the product of the first color gain and the second color gain, including: adjusting the second color gain according to image information of the first image to obtain an adjusted second color gain; and determining the product of the first color gain and the adjusted second color gain as the target color gain of the first image.
[0214] In an optional embodiment, the scene information is ambient light source information.
[0215] In an optional embodiment, the ambient light source information includes one or more of the following: color temperature of the ambient light source, and intensity of the ambient light source.
[0216] In practical applications, the acquisition module 51, calculation module 52, determination module 53 and compensation module 54 can be implemented by a processor located on the image processing device, specifically a CPU, a microprocessor (Microprocessor Unit, MPU), a digital signal processor (Digital Signal Processing, DSP) or a field programmable gate array (Field Programmable Gate Array, FPGA) and the like.
[0217] Figure 6 A schematic diagram of the structure of an optional electronic device provided in an embodiment of the present application, such as Figure 6As shown, an embodiment of the present application provides an electronic device 600, including:
[0218] A processor 61 and a storage medium 62 storing instructions executable by the processor; the storage medium 62 relies on the processor 61 to perform operations through a communication bus 63, and when the instructions are executed by the processor, the image processing method executed by the processor side in one or more of the above embodiments is executed.
[0219] It should be noted that in actual application, the various components in the computer device are coupled together through the communication bus 63. It is understandable that the communication bus 63 is used to realize the connection and communication between these components. In addition to the data bus, the communication bus 63 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 6 Various buses are labeled as communication buses 63.
[0220] An embodiment of the present application provides a computer storage medium storing executable instructions. When the executable instructions are executed by one or more processors, the processors execute the image processing method described in one or more of the above embodiments.
[0221] Among them, the computer-readable storage medium can be a ferromagnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and other memories.
[0222] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0223] The present application is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, and the combination of the process and / or box in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.
[0224] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0225] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0226] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A method for processing an image, characterized in that: include: Acquire a first image and a second image; wherein the second image is obtained by compensating the first image using a first color gain; and the first color gain is determined according to scene information of the first image; Obtaining a second color distribution image based on a gradient calculation of the first color distribution image of the second image; determining a second color gain according to the first color distribution image and the second color distribution image; The first image is compensated according to the first color gain and the second color gain to obtain an output image.
2. The method according to claim 1, characterized in that The step of calculating the gradient of the first color distribution image based on the second image to obtain the second color distribution image includes: Obtaining a gradient of the first color distribution image based on a gradient calculation of the first color distribution image of the second image; The second color distribution image is obtained based on the divergence calculation of the gradient of the first color distribution image.
3. The method according to claim 2, characterized in that The step of obtaining the second color distribution image by calculating the divergence of the gradient of the first color distribution image comprises: Calculating the divergence of the gradient of the first color distribution image to obtain the divergence of the first color distribution image; The boundary pixel value of the first color distribution image of the second image is used as a boundary condition, and Fourier transform is performed on the divergence of the first color distribution image to obtain a second color distribution image.
4. The method according to claim 2, characterized in that: The step of calculating the gradient of the first color distribution image based on the second image to obtain the gradient of the first color distribution image includes: According to the first color distribution image, a gradient of the first color distribution image in a preset direction is determined; wherein the preset direction includes: a preset X direction and a preset Y direction, and the X direction and the Y direction are perpendicular to each other.
5. The method according to claim 4, characterized in that The step of determining the gradient of the first color distribution image in a preset direction according to the first color distribution image includes: The pixel value of the next block of the current block of the first color distribution image along a preset direction is subtracted from the pixel value of the current block of the first color distribution image to obtain the gradient of the first color distribution image in the preset direction.
6. The method according to claim 3, characterized in that The step of calculating the divergence of the first color distribution image based on the gradient of the first color distribution image to obtain the divergence of the first color distribution image includes: According to the gradient of the first color distribution image in the preset direction, the divergence of the first color distribution image in the preset direction is determined; wherein the preset direction includes: a preset X direction and a preset Y direction, and the X direction and the Y direction are perpendicular to each other.
7. The method according to claim 6, characterized in that The step of determining the divergence of the first color distribution image in the preset direction according to the gradient of the first color distribution image in the preset direction includes: Setting the gradient of the first color distribution image in the preset direction that is less than the gradient threshold in the preset direction to zero, to obtain the actual gradient of the first color distribution image in the preset direction; The divergence of the first color distribution image in the preset direction is determined according to the actual gradient of the first color distribution image in the preset direction.
8. The method according to claim 7, characterized in that Determining the divergence of the first color distribution image in the preset direction according to the actual gradient of the first color distribution image in the preset direction includes: Subtracting the actual gradient of the previous block of the current block of the first color distribution image along each preset direction from the actual gradient of the current block of the first color distribution image in each preset direction, to obtain the divergence of the first color distribution image in each preset direction; The sum of the divergences of the first color distribution image in each preset direction is determined as the divergence of the first color distribution image in the preset direction.
9. The method according to claim 1, characterized in that: The acquiring of the first image and the second image comprises: Acquire a captured first image and scene information of the first image; Determine the first color gain under the scene information according to preset calibration data; wherein the calibration data is: a correspondence between the preset scene information and the color gain calibrated under the preset scene information; The first image is compensated by using the first color gain to obtain the second image.
10. The method according to claim 9, characterized in that The compensating the first image by using the first color gain to obtain the second image includes: Dividing the first image into grids according to the size of the first color gain to obtain a first image after grid division; The first color gain is used to compensate the first image after the grid division to obtain the second image.
11. The method according to claim 1, characterized in that: The determining a second color gain according to the first color distribution image and the second color distribution image comprises: The second color gain is determined according to a ratio of a pixel value of the second color distribution image to a pixel value of the first color distribution image.
12. The method according to claim 1, characterized in that The compensating the first image according to the first color gain and the second color gain to obtain an output image includes: determining a target color gain of the first image according to a product of the first color gain and the second color gain; The first image is compensated according to the target color gain to obtain the output image.
13. The method according to claim 12, characterized in that The step of determining a target color gain of the first image according to a product of the first color gain and the second color gain includes: A product of the first color gain and the second color gain is determined as a target color gain of the first image.
14. The method according to claim 12, characterized in that The step of determining a target color gain of the first image according to a product of the first color gain and the second color gain includes: adjusting the second color gain according to the image information of the first image to obtain an adjusted second color gain; A product of the first color gain and the adjusted second color gain is determined as a target color gain of the first image.
15. The method according to any one of claims 1 to 14, characterized in that The scene information is ambient light source information.
16. The method according to claim 15, characterized in that The ambient light source information includes one or more of the following: the color temperature of the ambient light source and the intensity of the ambient light source.
17. An image processing device, characterized in that: include: An acquisition module, used to acquire a first image and a second image; wherein the second image is obtained by compensating the first image using a first color gain; and the first color gain is determined according to scene information of the first image; A calculation module, configured to obtain a second color distribution image based on a gradient calculation of the first color distribution image; a determination module, configured to determine a second color gain according to the first color distribution image and the second color distribution image; A compensation module is used to compensate the first image according to the first color gain and the second color gain to obtain an output image.
18. An electronic device, characterized in that: include: A processor and a storage medium storing instructions executable by the processor; The storage medium relies on the processor to perform operations through a communication bus, and when the instructions are executed by the processor, the image processing method described in any one of claims 1 to 16 is executed.
19. A computer storage medium, characterized in that: Executable instructions are stored, and when the executable instructions are executed by one or more processors, the processors execute the image processing method described in any one of claims 1 to 16.