Image correction method and apparatus, mobile terminal and storage medium
By using Y component-oriented filtering method in YUV space, the image color difference problem is solved, and the image self-guided filtering is realized, color distortion and blurring is reduced, and the image clarity and color gradient effect are improved.
Patent Information
- Application Number
- CN202011408224.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-04
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2040-12-04
AI Technical Summary
The prior art is difficult to effectively solve the color aberration problem when processing images, resulting in image color distortion and blurring. Especially in the process of digital image processing, the common "purple edge" phenomenon and the overflow and distortion of image edge color are difficult to completely remove, affecting imaging. quality.
By obtaining the Y component, U component and V component in the YUV space, using the Y component as the guide image to guide filter the U component and V component, nonlinear fusion weight calculation and filtering are used to fuse pixel by pixel, reduce color difference and retain image details .
It realizes self-guided filtering of a single image without introducing other reference images, reducing color distortion and clarity improvement, improving image quality, and retaining color gradients well.
Smart Images

Figure CN112465721B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image technology, and in particular to an image correction method and device, a mobile terminal and a storage medium. Background Art
[0002] In an optical imaging system, the light emitted or reflected by an object passes through a lens and is refracted to the image plane to form an image plane. When natural light passes through a lens, because the refractive index of light of different colors (wavelengths) passing through the lens is different, it cannot be focused at the same point on the image plane, forming a chromatic aberration phenomenon. Chromatic aberration can often be observed at the junction of high and low light, specifically manifested as edges with color. The common "purple fringing" problem in digital photos is a significant manifestation of the chromatic aberration phenomenon, and the reasons for the occurrence of the "purple fringing" phenomenon are more complicated. In addition to the dispersion of the camera lens, it is also closely related to the size of the photosensitive element and the signal processing algorithm inside the digital camera. With the rapid development of portable digital cameras, the chromatic aberration problem has become more and more prominent. In addition to the common purple fringing, various image algorithms in the digital image processing process, such as noise reduction, super-resolution, feathering, etc., will also cause overflow and distortion of the color at the edge of the image. Chromatic aberration in digital images will seriously affect the image quality, causing the image color to be distorted and blurred.
[0003] In the related art, there is a method of removing excessive color patches or chromatic aberrations by image filtering, but this may cause image distortion of more pixels such as loss of image details. Summary of the invention
[0004] The present disclosure provides an image correction method and device, a mobile terminal and a storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an image correction method, comprising:
[0006] Acquire a first image through an image acquisition module;
[0007] Obtaining a Y component, a first U component, and a first V component of the first image in a YUV space;
[0008] According to the Y component, performing guided filtering on the first U component to obtain a second U component, and based on the Y component, performing guided filtering on the first V component to obtain a second V component;
[0009] A second image is obtained based on the Y component, the second V component and the second U component.
[0010] Based on the above solution, obtaining the second image based on the Y component, the second V component and the second U component includes:
[0011] Determine a first fusion weight according to a first absolute value of a difference between the first U component and the second U component; wherein a weight value in the first fusion weight and the first absolute value of a corresponding pixel have a nonlinear relationship;
[0012] Determine a second fusion weight according to a second absolute value of a difference between the first V component and the second V component; wherein a weight value in the second fusion weight and the second absolute value of a corresponding pixel have a nonlinear relationship;
[0013] Obtain a third U component according to the first fusion weight and the second U component;
[0014] Obtain a third V component according to the second fusion weight and the second V component;
[0015] The Y component, the third U component and the third V component are fused to obtain the second image.
[0016] Based on the above solution, determining a first fusion weight according to a first absolute value of a difference between the first U component and the second U component includes:
[0017] Based on the first absolute value, performing a nonlinear transformation to obtain the first fusion weight;
[0018] The determining a second fusion weight according to a second absolute value of a difference between the first V component and the second V component includes:
[0019] Based on the second absolute value, a nonlinear transformation is performed to obtain the second fusion weight.
[0020] Based on the above solution, performing a nonlinear transformation based on the first absolute value to obtain the first fusion weight includes:
[0021] Normalizing the first absolute value to obtain the normalized first absolute value;
[0022] Performing the nonlinear transformation on the normalized first absolute value to obtain the first fusion weight;
[0023] The performing a nonlinear transformation based on the second absolute value to obtain the second fusion weight includes:
[0024] normalizing the second absolute value to obtain the normalized second absolute value;
[0025] The nonlinear transformation is performed on the normalized second absolute value to obtain the second fusion weight.
[0026] Based on the above scheme, the functions used in the nonlinear transformation include:
[0027] Inverse tangent function;
[0028] or,
[0029] Exponential function.
[0030] Based on the above solution, obtaining a second image based on the Y component, the second V component and the second U component includes:
[0031] Determining a first pixel to be corrected and a second pixel to be maintained according to the first absolute value;
[0032] determining a third pixel to be corrected and a fourth pixel to be maintained according to the second absolute value;
[0033] The second image is obtained by performing pixel-by-pixel fusion based on the third U component of the first pixel, the first U component of the second pixel, the third V component of the third pixel, the first V component of the fourth pixel, and the Y component.
[0034] Based on the above solution, determining the first pixel to be corrected and the second pixel to be maintained according to the first absolute value includes:
[0035] Obtaining a descending order of first absolute values of different pixels in the first image, and selecting, according to the ordering result, a preset percentage of pixels whose first absolute values are ranked first as the first pixels, and determining pixels other than the first pixels as the second pixels;
[0036] The step of determining the third pixel to be corrected and the fourth pixel to be maintained according to the second absolute value comprises:
[0037] Obtain a descending order of the second absolute values of different pixels in the first image, and according to the ordering result, select the preset percentage of pixels whose second absolute values are ranked first as the third pixels, and determine the pixels other than the third pixels as the fourth pixels.
[0038] According to a second aspect of an embodiment of the present disclosure, there is provided an image correction device, comprising:
[0039] An acquisition module, used for acquiring a first image through an image acquisition module;
[0040] An acquisition module, used to acquire a Y component, a first U component and a first V component of the first image in a YUV space;
[0041] a filtering module, configured to perform guided filtering on the first U component according to the Y component to obtain a second U component, and perform guided filtering on the first V component based on the Y component to obtain a second V component;
[0042] A fusion module is used to obtain a second image based on the Y component, the second V component and the second U component.
[0043] Based on the above scheme, the fusion module is specifically used to determine a first fusion weight according to a first absolute value of the difference between the first U component and the second U component; wherein there is a nonlinear relationship between the weight value in the first fusion weight and the first absolute value of the corresponding pixel; determine a second fusion weight according to a second absolute value of the difference between the first V component and the second V component; wherein there is a nonlinear relationship between the weight value in the second fusion weight and the second absolute value of the corresponding pixel; obtain a third U component according to the first fusion weight and the second U component; obtain a third V component according to the second fusion weight and the second V component; and fuse the Y component, the third U component and the third V component to obtain the second image.
[0044] Based on the above solution, the fusion module is specifically used to perform a nonlinear transformation based on the first absolute value to obtain the first fusion weight; and perform a nonlinear transformation based on the second absolute value to obtain the second fusion weight.
[0045] Based on the above scheme, the fusion module is specifically used to normalize the first absolute value to obtain the normalized first absolute value; perform the nonlinear transformation on the normalized first absolute value to obtain the first fusion weight; normalize the second absolute value to obtain the normalized second absolute value; perform the nonlinear transformation on the normalized second absolute value to obtain the second fusion weight.
[0046] Based on the above scheme, the functions used in the nonlinear transformation include:
[0047] Inverse tangent function;
[0048] or,
[0049] Exponential function.
[0050] Based on the above scheme, the fusion module is specifically used to determine the first pixel to be corrected and the second pixel to be maintained according to the first absolute value; determine the third pixel to be corrected and the fourth pixel to be maintained according to the second absolute value; perform pixel-by-pixel fusion based on the third U component of the first pixel, the first U component of the second pixel, the third V component of the third pixel, the first V component of the fourth pixel and the Y component to obtain the second image.
[0051] Based on the above scheme, the fusion module is specifically used to obtain the descending order of the first absolute values of different pixels in the first image, and according to the ordering result, select the preset percentage of pixels with the first absolute value ordering at the front as the first pixel, and determine the pixels other than the first pixel as the second pixel; obtain the descending order of the second absolute values of different pixels in the first image, and according to the ordering result, select the preset percentage of pixels with the second absolute value ordering at the front as the third pixel, and determine the pixels other than the third pixel as the fourth pixel.
[0052] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0053] a memory for storing processor-executable instructions;
[0054] A processor connected to the memory;
[0055] Wherein, the processor is configured to execute the above image correction method.
[0056] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of a computer, the computer is enabled to perform the above image correction method.
[0057] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0058] The Y component, V component and U component of the first image in the YUV space are obtained; the Y component retains more image details than the U component and the V component; the Y component is used as the guiding image of the guided filtering, and the U component and the V component are guided and filtered respectively. In this way, the Y component is equivalent to providing constraints for the filtering of the U component and the V component, reducing the filtering distortion caused by uncontrollable filtering without constraints. Therefore, the second image is corrected in this way. On the one hand, it can reduce the phenomenon of color distortion during the acquisition process, and on the other hand, it can reduce the distortion introduced by the correction, and obtain a second image with less color distortion and high clarity, which has the characteristics of good image correction effect. At the same time, without introducing other reference images, the guided filtering of the U component and the V component is directly based on the Y component to realize the self-guided filtering of a single image. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0060] Figure 1 is a flowchart of an image correction method according to an exemplary embodiment;
[0061] Figure 2A is a schematic diagram showing the effect of color overflow of a contour edge according to an exemplary embodiment;
[0062] Figure 2B is a schematic diagram showing the effect of color expansion of a contour edge according to an exemplary embodiment;
[0063] Figure 2C is a schematic diagram showing the effect after correction according to an exemplary embodiment;
[0064] Figure 3 is a schematic diagram of a process of obtaining a second image based on the fusion of a Y component, a second U component and a second V component according to an exemplary embodiment;
[0065] Figure 4 is a schematic structural diagram of an image correction device according to an exemplary embodiment;
[0066] Figure 5A is a schematic diagram showing the effect of comparing U images corresponding to U components before and after correction according to an exemplary embodiment;
[0067] Figure 5B is a schematic diagram showing the effect of comparing U images corresponding to U components before and after correction according to an exemplary embodiment;
[0068] Figure 5C is a schematic diagram showing the effect of comparing U images corresponding to U components before and after correction according to an exemplary embodiment;
[0069] Figure 5D is a schematic diagram showing the effect of comparing U images corresponding to V components before and after correction according to an exemplary embodiment;
[0070] Figure 5E is a schematic diagram showing the effect of comparing U images corresponding to V components before and after correction according to an exemplary embodiment;
[0071] Fig. 5F is a schematic diagram showing the effect of comparing U images corresponding to V components before and after correction according to an exemplary embodiment;
[0072] Figure 6 It is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0073] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices consistent with some aspects of the present disclosure as detailed in the appended claims.
[0074] like Figure 1 As shown, the embodiment of the present disclosure provides an image correction method, which is applied to a mobile terminal, including:
[0075] S100: Acquire a first image through an image acquisition module;
[0076] S110: Obtain a Y component, a first U component, and a first V component of the first image in a YUV space;
[0077] S120: According to the Y component, perform guided filtering on the first U component to obtain a second U component, and based on the Y component, perform guided filtering on the first V component to obtain a second V component;
[0078] S130: Obtain a second image based on the Y component, the second V component and the second U component;
[0079] In the embodiments of the present disclosure, the method can be applied to various electronic devices. For example, the image correction method can be applied to a terminal or a server. The terminal may include: a mobile terminal and a fixed terminal. Typical fixed terminals include but are not limited to: a large-screen TV or a desktop computer.
[0080] The mobile terminal includes but is not limited to at least one of the following electronic devices: a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device or a smart device. The smart device includes but is not limited to: a smart home device and / or a smart office device.
[0081] For example, the image correction method can be applied to an image acquisition application, which can correspond to a camera application in a terminal. In this way, after the image acquisition module of the mobile terminal is completed, this method can be applied to correct the "purple fringing" phenomenon introduced by the hardware characteristics of the lens itself, or the image distortion phenomenon introduced during image optimization such as image beautification. After the image correction method is introduced, the acquired image is corrected or the beautified image is corrected, and the corrected image is previewed or saved after correction, so that the user will not see the "purple fringing" phenomenon or image quality problems such as overflow or inward expansion at the edge of the contour in image processing, thereby improving the image quality seen by the user.
[0082] The image acquisition module may be a camera in a mobile terminal, and the camera includes: a camera and an image sensor located in the light emission direction of the camera.
[0083] The image data of the first image in the YUV space is obtained, that is, the Y component, the U component, and the V component of each pixel in the first image are obtained; here, the original U component of each pixel in the first image is referred to as the first U component, and the original V component of each pixel in the first image is referred to as the first V component.
[0084] The Y component of each pixel in the first image will constitute a Y image; the first U component of each pixel in the first image will constitute a U image; and the first V component of each pixel in the first image will constitute a V image.
[0085] If the first image is an image other than the YUV format, then according to the conversion relationship between different image formats, the images in other formats are converted into images in the YUV format, and image data of the first image in the YUV space can be obtained.
[0086] For example, if the first image is currently an RGB image, it is necessary to convert the RGB data of the first image into image data of a YUV image, that is, data corresponding to the Y component, the U component, and the V component, according to the conversion relationship between the RGB image and the YVU image.
[0087] For example, the following is an example of the conversion relationship between an RGB image and a YUV image:
[0088] Y (x,y) =0.299*R (x,y) +0.587*G (x,y) +0.114*B (x,y) ;
[0089] U=-0.1678*R (x,y) –0.3313*G (x,y) +0.5*B (x,y) ;
[0090] V 0.5*R (x,y) -0.4187*G (x,y) -0.0813*B (x,y) ;
[0091] (x,y) is the pixel coordinate, Y (x,y) is the Y component of the pixel with coordinates (x,y); U (x,y) is the U component of the pixel with coordinates (x, y); V (x,y) is the V component of the pixel with coordinates (x,y). (x,y) The R value of the pixel with coordinates (x, y); G (x,y)The G value of the pixel with coordinates (x, y); B (x,y) The B value of the pixel at coordinates (x,y).
[0092] In the disclosed embodiment, the Y component represents the brightness of the image; and the brightness itself does not have color difference. And the outlines and features of different objects in the image will be more obvious in the Y component. The U component and the V component are components that describe the corresponding pixel color and color saturation, respectively, and are closely related to color difference. Based on this feature, in the disclosed embodiment, when the guided filtering of the U component and the V component is performed, the Y component is not filtered, that is, the Y component is maintained unchanged.
[0093] Furthermore, in the disclosed embodiment, the U component and the V component are subjected to guided filtering, and the Y component is used as the guided image for filtering. In view of this, the filtering distortion caused by uncontrollable filtering without constraints is reduced. Therefore, the second image is corrected in this way. On the one hand, the color distortion during the acquisition process can be reduced, and on the other hand, the distortion introduced by the correction can be reduced, and the second image with less color distortion and high clarity is obtained, which has the characteristics of good image correction effect.
[0094] Figure 2A This is a schematic diagram of the corresponding contours of color overflow in the image due to the processing of acquisition or image beautification, for example, Figure 2A The lip color on the middle and lower lips overflows the lower lip line. Figure 2B This is a schematic diagram where the color does not fill the outline of the image due to the processing of acquisition or image beautification, for example, Figure 2B The color fill in the middle lip does not cover the entire lower lip. Figure 2C Yes Figure 2A and Figure 2B The image after image correction. At this time, Figure 2A or Figure 2B Equivalent to the first image in the embodiment of the present disclosure; Figure 2C This is the second image of the embodiment of the present disclosure.
[0095] In one embodiment, the second image can be obtained by directly fusing the filtered second U component and the second V component with the Y component without introducing weights. However, the second image obtained in this way, although it is not constrained by the Y component, removes the color or color cast while maintaining the outline of the image object in the image, but it may cause the gradient between colors to be lost. In view of this, in order to retain more color gradients, weights will be introduced when different components are fused. For example, different pixels have different weight values, so that the second image obtained based on the weight value and the second U component, based on the weight value and the second V component and the Y component, will retain or increase the color gradient, so that the corrected second image is more similar to the characteristics presented by various scenes in the captured scene, thereby improving the realism of the second image.
[0096] Different pixels have different weights, and the weight value has a corresponding relationship with the correction value of the pixel in the guided filtering process. For example, the weight value is positively correlated with the correction value of the pixel in the guided filtering, but this positive correlation is not a linear relationship.
[0097] In some embodiments, Figure 3 As shown, the S130 may include:
[0098] S131: determining a first fusion weight according to a first absolute value of a difference between the first U component and the second U component; wherein a weight value in the first fusion weight and the first absolute value of a corresponding pixel have a nonlinear relationship;
[0099] S132: determining a second fusion weight according to a second absolute value of a difference between the first V component and the second V component; wherein a weight value in the second fusion weight and the second absolute value of a corresponding pixel have a nonlinear relationship;
[0100] S133: Obtain a third U component according to the first fusion weight and the second U component;
[0101] S134: Obtain a third V component according to the second fusion weight and the second V component;
[0102] S135: Fusing the Y component, the third U component and the third V component to obtain the second image.
[0103] In the embodiment of the present disclosure, the first fusion weight and the second fusion weight are both pixel-level fusion weights, that is, one weight value of the first fusion weight corresponds to one pixel.
[0104] In one embodiment, the size relationship between each weight value in the first fusion weight and the first absolute value of different pixels is nonlinearly distributed; and the size relationship between each weight value in the second fusion weight and the second absolute value of different pixels is nonlinearly distributed.
[0105] For example, if the first absolute value of pixel n is the dependent variable, the weight value of pixel n in the first fusion weight is the independent variable; if the first absolute value of pixel m is the dependent variable, the weight value of pixel m in the first fusion weight is the independent variable, and function fitting is performed, a nonlinear function is obtained, rather than a linear function. Similarly, if the second absolute value of pixel n is the dependent variable, the weight value of pixel n in the second fusion weight is the independent variable; if the second absolute value of pixel m is the dependent variable, the weight value of pixel m in the second fusion weight is the independent variable, and function fitting is performed, a nonlinear function is obtained, rather than a linear function.
[0106] In one embodiment, the nonlinear distribution law between the first absolute value and the first fusion weight may be the same as the nonlinear distribution law between the second absolute value and the second fusion weight. Such nonlinear distribution law may be fitted as an inverse tangent function or an exponential function.
[0107] In one embodiment, this nonlinear distribution law also has the following characteristics:
[0108] There is a nonlinear positive correlation between the first absolute value of pixel n and the weight value of pixel n of the first fusion weight; and / or there is a nonlinear positive correlation between the first absolute value of pixel n and the weight value of pixel n of the first fusion weight.
[0109] In one embodiment, the first fusion weight and the second fusion weight correspond to weight values of each pixel, and both can be natural numbers between 0 and 1.
[0110] The maximum value of the positive correlation is 1 and the minimum value is 0 by constructing the nonlinearity.
[0111] By introducing the weight value of this nonlinear relationship, the gradient between color and brightness can be retained in the second image. After repeated experiments, it is found that this nonlinear positive correlation is very similar to the gradient of light emitted by objects in the real environment. Therefore, the second image has high realism and on-site restoration, so the second image has high image quality.
[0112] In some embodiments, the S131 may include: performing a nonlinear transformation based on the first absolute value to obtain the first fusion weight;
[0113] The S132 may include: performing a nonlinear transformation based on the second absolute value to obtain the second fusion weight.
[0114] In one embodiment, the first fusion weight and the second fusion weight are obtained by directly performing nonlinear transformation on the first absolute value and the second absolute value, respectively, which has the characteristic of simple implementation.
[0115] In another embodiment, in addition to directly processing the first absolute value and the second absolute value, the first absolute value and the second absolute value of different pixels may be linearly processed to obtain the first absolute value after linear processing and the second absolute value after linear processing; then, the first absolute value after linear processing and the second absolute value after linear processing may be nonlinearly transformed to obtain the first fusion weight and the second fusion weight.
[0116] For example, the S131 may include: normalizing the first absolute value to obtain the normalized first absolute value; and performing the nonlinear transformation on the normalized first absolute value to obtain the first fusion weight;
[0117] The S132 may include: normalizing the second absolute value to obtain the normalized second absolute value; and performing the nonlinear transformation on the normalized second absolute value to obtain the second fusion weight.
[0118] In the embodiment of the present disclosure, the first absolute value and the second absolute value are first normalized. The normalization process here is a linear process, and the normalized first absolute value and the normalized second absolute value are brought together to the interval of 0 to 1. Compared with the first absolute value and the second absolute value before normalization, the calculation value involved in the linear transformation process is small, which reduces the amount of calculation.
[0119] In some embodiments, the function used for the nonlinear transformation includes: an inverse tangent function; or an exponential function.
[0120] The inverse tangent function and the exponential function are both commonly used functions, and are simple to calculate and can meet the requirements of nonlinear positive correlation.
[0121] In one embodiment, filtering processing may be performed on all pixels of the original U component and V component of the first image. However, such filtering may inevitably introduce distortion. Therefore, in this embodiment, the S130 may include:
[0122] Determining a first pixel to be corrected and a second pixel to be maintained according to the first absolute value;
[0123] determining a third pixel to be corrected and a fourth pixel to be maintained according to the second absolute value;
[0124] The second image is obtained by performing pixel-by-pixel fusion based on the third U component of the first pixel, the first U component of the second pixel, the third V component of the third pixel, the first V component of the fourth pixel, and the Y component.
[0125] In this way, only the U component is filtered for the first pixel, and only the V component is filtered for the third pixel, which reduces unnecessary U component filtering and V component filtering, so that the image quality of the second image is further improved.
[0126] In one embodiment, determining the first pixel to be corrected and the second pixel to be maintained according to the first absolute value includes:
[0127] Obtaining a descending order of first absolute values of different pixels in the first image, and selecting, according to the ordering result, a preset percentage of pixels whose first absolute values are ranked first as the first pixels, and determining pixels other than the first pixels as the second pixels;
[0128] The step of determining the third pixel to be corrected and the fourth pixel to be maintained according to the second absolute value comprises:
[0129] Obtain a descending order of the second absolute values of different pixels in the first image, and according to the ordering result, select the preset percentage of pixels whose second absolute values are ranked first as the third pixels, and determine the pixels other than the third pixels as the fourth pixels.
[0130] In the embodiment of the present disclosure, the preset percentage may be a predetermined arbitrary value, for example, a predetermined empirical value or an experimental value. The preset percentage may range from 1% to 5%.
[0131] The first U component of all pixels is filtered to obtain the second U component; then the absolute value of the difference between the first U component and the second U component is calculated, and 5% of the pixels with the largest absolute value are selected as the first pixels by sorting, and then the second U component of the selected first pixel and the weight value of the first pixel corresponding to the first fusion weight value are multiplied to obtain the third U component of the first pixel; in this way, after the third U component of the first pixel and the first U component of the second pixel are fused, the U component of the second image is obtained.
[0132] Similarly, the first V components of all pixels are filtered to obtain the second V component; then the absolute value of the difference between the first V component and the second V component is calculated, and the 5% of pixels with the largest absolute values are selected as the first pixels by sorting, and then the second V component of the selected first pixel and the weight value of the third pixel corresponding to the second fusion weight value are multiplied to obtain the third V component of the third pixel; in this way, after the third V component of the third pixel and the first V component of the fourth pixel are fused, the V component of the second image is obtained.
[0133] The U component and the V component with the largest difference before and after the guided filtering are both places where the color difference deviation is large. Therefore, this method can filter only the pixels that need to be filtered, thereby reducing the distortion of the second image as much as possible.
[0134] In one embodiment, the original image format of the first image is not a YUV format corresponding to the YUV space. After obtaining the second image in YUV format, the image format of the second image is converted according to the original image format of the first image to obtain a second image with the same original image format as the first image.
[0135] For example, if the original image format of the first image is RGB format, the second image in YUV format is converted into RGB space to obtain a second image in RGB format corresponding to the RGB space.
[0136] Here, the second image in YUV format is converted to the second image in RGB format. The mapping relationship used is as follows:
[0137] R(x,y)=Y(x,y)+1.4075*(V(x,y)-128);
[0138] G(x,y)=Y(x,y)-0.3455*(U(x,y)-128)-0.7169*(V(x,y)-128);
[0139] B(x,y)=Y(x,y)+1.779*(U(x,y)-128).
[0140] (x,y) is the pixel coordinate, Y(x,y) is the Y component of the pixel with coordinates (x,y); U(x,y) is the U component of the pixel with coordinates (x,y); V(x,y) is the V component of the pixel with coordinates (x,y). R(x,y) is the R value of the pixel with coordinates (x,y); G(x,y) is the G value of the pixel with coordinates (x,y); B(x,y) is the B value of the pixel with coordinates (x,y).
[0141] In one embodiment, the method further comprises:
[0142] uniformly downsampling the first U component and the first V component;
[0143] The S120 may include: based on the uniformly downsampled Y component, performing guided filtering on the downsampled first U component and the first V component respectively to obtain a second U component and a second V component;
[0144] Thus, in S130, based on the fusion of the uniformly downsampled Y component, the second U component and the second V component, a third image with the number of pixels after downsampling is obtained; based on the sampling coefficient of the aforementioned uniform downsampling, the third image is upsampled to obtain the aforementioned second image in the YUV format.
[0145] Since the first image generally acquired has smooth characteristics in both the U component and the V component, the amount of calculation can be reduced by downsampling, and the loss of image quality is very small. Therefore, not only a second image with higher image quality can be obtained, but also the amount of calculation is small.
[0146] The image correction method provided in this embodiment can realize the color difference correction of digital images. The method includes but is not limited to the common "purple edge", noise reduction, compression, feathering and other digital image processing algorithms that cause the color overflow or expansion at the edge of the image. The abnormal color difference of the area with color difference, such as purple edge, is removed and filled. The filled color is a natural restoration of its original color, which greatly improves the quality and visual experience of the color difference image.
[0147] When fusing the three components in the YUV space, nonlinear weight values are used for fusion. While correcting the color difference area, the normal color gradient of the original image is not changed, and the color difference-free area of the original image is affected as little as possible.
[0148] Step 1: Convert the image I_RGB from RGB space to YUV space to obtain I_Y, I_U, I_V; here I_Y is the aforementioned Y component; I_U is the aforementioned first U component; I_V is the aforementioned first V component; Step 2: Take I_Y as the guide image, perform fast guided filtering on I_U, I_V, and obtain IG_U, IG_V; here IG_U is the aforementioned second U component after guided filtering; IG_V is the aforementioned second V component after guided filtering;
[0149] Step 3: Calculate the absolute value differences between IG_U, IG_V and I_U, I_V respectively to obtain Diff_U, Diff_V; here, Diff_U is the aforementioned first absolute value; Diff_V is the aforementioned second absolute value;
[0150] Step 4: Normalize Diff_U and Diff_V to obtain Diff_NormU and Diff_NormV; Diff_NormU is the first absolute value after normalization; Diff_NormV is the second absolute value after normalization;
[0151] Step 5: Perform nonlinearization on Diff_NormU and Diff_NormV respectively to obtain weight maps W_U and W_V; W_U is the first fusion weight mentioned above; W_V is the second fusion weight mentioned above;
[0152] Step 6: Fuse I_U, I_V with IG_U, IG_V with weight graphs W_U, W_V to obtain fused O_U, O_V;
[0153] Step 7: Combine I_Y with O_U and O_V to obtain the processed YUV image O_YUV; O_YUV is the second image in the aforementioned YUV format;
[0154] Step 8: Convert O_YUV from YUV space to RGB space to get the final output O_RGB. O_RGB is the corrected RGB image.
[0155] The specific detailed steps and results are shown as follows:
[0156] 1) YUV space separates brightness information and color information. The Y channel contains rich image detail information and is not affected by color. Selecting the Y channel as the reference channel has an inherent advantage in processing image color difference and edge color overflow.
[0157] Y=0.299*R+0.587*G+0.114*B;
[0158] U=-0.1678*R–0.3313*G+0.5*B;
[0159] V 0.5*R-0.4187*G-0.0813*B;
[0160] 2) Select Y as the guide image and perform guided filtering on UV. The downsampling factor k can be input for the fast guided filtering algorithm to obtain acceleration. Because the UV channel itself contains very little detail information, downsampling will basically have no effect. Perform guided filtering on the U and V channels respectively to obtain IG_U and IG_V. The Y channel contains the main image detail information. The Y channel guides the UV channel for guided filtering, which can constrain the U and V channel values that overflow or scatter to the edge to the edge of the image, so that the color difference can be corrected and filled with its original color.
[0161] 3) The above steps have eliminated the color difference. In order to avoid color changes in the normal area without color difference in the image, the filtered image needs to be fused with the original image. Since the Y channel has not changed, only the U and V channels need to be fused. The fusion weight is obtained by calculating the changes in U and V before and after filtering.
[0162] Diff_U = abs(IG_U - I_U)
[0163] Diff_V=abs(IG_V-I_V)
[0164] 4) In order to match the absolute difference with the fusion weight, the absolute difference is normalized and transformed to between 0 and 1.
[0165] Diff_NormU=(Diff_U-Diff_U.min()) / (Diff_U.max()-Diff_U.min())
[0166] Diff_NormV=(Diff_V-Diff_V.min()) / (Diff_V.max()-Diff_V.min())
[0167] 5) The absolute difference of the U and V channels before and after the guided filtering obtained in step 3 is respectively subjected to a nonlinear function, which can be used but not limited to the inverse tangent function, exponential function, etc.; here we use the inverse tangent function to perform a nonlinear transformation on the aforementioned absolute difference; since the color of the area with color difference returns to the normal value after the guided filtering, the color difference is large, while the area with small color difference after the guided filtering is compared with the normal color gradient at the edge in the original image, and its value should not be modified by the guided filtering. After the nonlinear transformation of the absolute difference, the higher absolute difference corresponds to a relatively larger weight (gradually changing from 0 to 1) to correct the color difference, and the smaller difference is made as close to 0 as possible to maintain the hue of the original image. The selection of the U and V critical values can be obtained by performing histogram statistics on Diff_NormU and Diff_NormV, and the critical value is selected so that the pixels corresponding to the difference less than the critical value account for no less than a percentage (95%) of the original image. The U and V channel weight maps after nonlinear transformation are recorded as W_U and W_V respectively. The critical value here can be determined according to the percentage, which is the aforementioned preset percentage.
[0168] 6) The original image and the U and V channels after the guided filtering are fused according to the weight map obtained in step 5.
[0169] O_U=IG_U*W_U+I_U*(1-W_U)
[0170] O_V=IG_V*W_V+I_V*(1-W_V)
[0171] 7) Connect the fused U and V channels with the Y channel of the original image to obtain the processed YUV image O_YUV.
[0172] 8) Convert the processed image from YUV space to RGB space.
[0173] R = Y + 1.4075 * (V - 128);
[0174] G=Y-0.3455*(U-128)-0.7169*(V-128);
[0175] B=Y+1.779*(U-128)
[0176] This technical solution uses the Y channel in the YUV space to contain the main details of the image, and guides the smoother UV channel to correct the abnormal color changes that overflow or expand at the edge of the image, restore it to its original normal color, and at the same time avoid color changes in normal areas without color difference. Guided filtering of the UV channel using the Y channel as a guide image can not only eliminate color difference; it can also achieve self-guided filtering of a single image without introducing other reference images.
[0177] The fast guided filtering algorithm can accelerate the execution of the algorithm. Due to the smooth characteristics of the U component and the V channel, a larger downsampling factor can be introduced, which greatly improves the execution speed of the algorithm.
[0178] The method proposed in the embodiment of the present disclosure for separating the Y and UV channels, using the Y component as a guide image for guided filtering, and modifying the U and V components is not limited to chromatic aberration correction, but can also be expanded to applications such as color noise reduction, image coloring, and chromatic aberration correction data set production.
[0179] Figure 5A The middle left picture is the U image corresponding to the U component before correction. Figure 5A The middle right picture is the U image corresponding to the U component corrected by the image correction method provided by the embodiment of the present disclosure;
[0180] Figure 5B The middle left picture is the U image corresponding to the U component before correction. Figure 5B The middle right picture is the U image corresponding to the U component corrected by the image correction method provided by the embodiment of the present disclosure;
[0181] Figure 5C The middle left picture is the U image corresponding to the U component before correction. Figure 5C The middle right picture is the U image corresponding to the U component after correction using the image correction method provided by the embodiment of the present disclosure.
[0182] pass FIG. 5A to FIG. 5CBy comparing the U corresponding to the U component before and after correction, it can be seen that the effect of the image correction method provided by the embodiment of the present disclosure is very obvious, and has an obvious smoothing effect.
[0183] Figure 5D The middle left picture is the V image corresponding to the V component before correction. Figure 5D The middle right picture is a V image corresponding to the V component corrected by the image correction method provided by the embodiment of the present disclosure;
[0184] Figure 5E The middle left picture is the V image corresponding to the V component before correction. Figure 5E The middle right picture is the U image corresponding to the V component after correction using the image correction method provided by the embodiment of the present disclosure;
[0185] Fig. 5F The middle left picture is the V image corresponding to the V component before correction. Fig. 5F The middle right picture is a V image corresponding to the V component corrected by the image correction method provided by the embodiment of the present disclosure.
[0186] pass FIG. 5D to FIG. 5E By comparing the V corresponding to the V component before and after correction, it can be seen that the effect of the image correction method provided by the embodiment of the present disclosure is very obvious, and has an obvious smoothing effect.
[0187] Since the U component and the V component correspond to the color and color saturation of a pixel respectively, many color casts and dispersion phenomena can be filtered out through this smoothing, thereby achieving high-quality image correction.
[0188] like Figure 6 As shown, the embodiment of the present disclosure provides an image correction device, comprising:
[0189] The acquisition module 100 is used to acquire a first image through an image acquisition module;
[0190] The acquisition module 110 is used to acquire a Y component, a first U component and a first V component of the first image in a YUV space; the filtering module 120 is used to perform guided filtering on the first U component according to the Y component to obtain a second U component, and to perform guided filtering on the first V component based on the Y component to obtain a second V component;
[0191] The fusion module 130 is used to obtain a second image based on the Y component, the second V component and the second U component.
[0192] In some embodiments, the acquisition module 100, the acquisition module 110, the filtering module 120 and the fusion module 130 may be pure software modules; after the pure software modules are executed by the processor, they can perform guided filtering of the U component and the V component of the first image to obtain a second image that retains more image details.
[0193] In some embodiments, the acquisition module 100, the acquisition module 110, the filtering module 120 and the fusion module 130 may be a combination of soft and hard modules; the combination of soft and hard modules include but are not limited to programmable arrays; programmable arrays include but are not limited to: field programmable arrays or complex programmable arrays.
[0194] In some other embodiments, the acquisition module 100, the acquisition module 110, the filtering module 120 and the fusion module 130 may be pure hardware modules; pure hardware modules include but are not limited to: application-specific integrated circuits.
[0195] In one embodiment, the acquisition module 100 and the fusion module 130 are specifically used to determine a first fusion weight according to a first absolute value of the difference between the first U component and the second U component; wherein there is a nonlinear relationship between the weight value in the first fusion weight and the first absolute value of the corresponding pixel; determine a second fusion weight according to a second absolute value of the difference between the first V component and the second V component; wherein there is a nonlinear relationship between the weight value in the second fusion weight and the second absolute value of the corresponding pixel; obtain a third U component according to the first fusion weight and the second U component; obtain a third V component according to the second fusion weight and the second V component; and fuse the Y component, the third U component and the third V component to obtain the second image.
[0196] In one embodiment, the fusion module 130 is specifically configured to perform a nonlinear transformation based on the first absolute value to obtain the first fusion weight; and perform a nonlinear transformation based on the second absolute value to obtain the second fusion weight.
[0197] In one embodiment, the fusion module 130 is specifically used to normalize the first absolute value to obtain the normalized first absolute value; perform the nonlinear transformation on the normalized first absolute value to obtain the first fusion weight; normalize the second absolute value to obtain the normalized second absolute value; perform the nonlinear transformation on the normalized second absolute value to obtain the second fusion weight.
[0198] In one embodiment, the function used in the nonlinear transformation includes:
[0199] Inverse tangent function;
[0200] or,
[0201] Exponential function.
[0202] In one embodiment, the fusion module 130 is specifically used to determine a first pixel to be corrected and a second pixel to be maintained according to the first absolute value; determine a third pixel to be corrected and a fourth pixel to be maintained according to the second absolute value; and perform pixel-by-pixel fusion based on the third U component of the first pixel, the first U component of the second pixel, the third V component of the third pixel, the first V component of the fourth pixel and the Y component to obtain the second image.
[0203] In one embodiment, the fusion module 130 is specifically used to obtain a descending ordering of the first absolute values of different pixels in the first image, and according to the ordering result, select a preset percentage of pixels with the first absolute value ordering at the front as the first pixels, and determine the pixels other than the first pixels as the second pixels; obtain a descending ordering of the second absolute values of different pixels in the first image, and according to the ordering result, select the preset percentage of pixels with the second absolute value ordering at the front as the third pixels, and determine the pixels other than the third pixels as the fourth pixels.
[0204] An embodiment of the present disclosure provides an electronic device, including:
[0205] a memory for storing processor-executable instructions;
[0206] A processor connected to the memory;
[0207] The processor is configured to execute the image correction method provided by any of the aforementioned technical solutions.
[0208] The processor may include various types of storage media, which are non-transitory computer storage media that can continue to retain information stored thereon after the communication device loses power.
[0209] The electronic device may be a terminal or a server.
[0210] The processor can be connected to the memory through a bus or the like, and is used to read the executable program stored in the memory, for example, to execute the following Figure 1 and / or Figure 3 At least one of the methods shown.
[0211] Figure 6 8 is a block diagram of an electronic device 800 according to an exemplary embodiment. For example, the electronic device 800 may be a mobile phone, a mobile computer, etc.
[0212] Reference Figure 6, the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0213] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0214] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0215] The power component 806 provides power to the various components of the electronic device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.
[0216] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating state, such as a shooting state or a video state, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0217] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating state, such as a call state, a recording state, and a voice recognition state, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0218] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0219] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0220] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0221] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0222] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the above instructions can be executed by the processor 820 of the electronic device 800 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0223] The present disclosure provides a non-transitory computer-readable storage medium. When the instructions in the storage medium are executed by a processor of a UE, the UE can execute the image correction method provided in any of the above embodiments, and can execute Figure 1 and / or Figure 3 At least one of the methods shown.
[0224] The image correction method includes: acquiring a first image through an image acquisition module; acquiring a Y component, a first U component and a first V component of the first image in a YUV space; performing guided filtering on the first U component according to the Y component to obtain a second U component, and performing guided filtering on the first V component based on the Y component to obtain a second V component; and obtaining a second image based on the Y component, the second V component and the second U component.
[0225] It can be understood that obtaining the second image based on the Y component, the second V component and the second U component includes: determining a first fusion weight according to a first absolute value of the difference between the first U component and the second U component; wherein there is a non-linear relationship between the weight value in the first fusion weight and the first absolute value of the corresponding pixel; determining a second fusion weight according to a second absolute value of the difference between the first V component and the second V component, wherein there is a non-linear relationship between the weight value in the second fusion weight and the second absolute value of the corresponding pixel; obtaining a third U component according to the first fusion weight and the second U component; obtaining a third V component according to the second fusion weight and the second V component; and fusing the Y component, the third U component and the third V component to obtain the second image.
[0226] It can be understood that determining the first fusion weight according to the first absolute value of the difference between the first U component and the second U component includes: performing a nonlinear transformation based on the first absolute value to obtain the first fusion weight; determining the second fusion weight according to the second absolute value of the difference between the first V component and the second V component includes: performing a nonlinear transformation based on the second absolute value to obtain the second fusion weight.
[0227] It can be understood that the nonlinear transformation based on the first absolute value to obtain the first fusion weight includes: normalizing the first absolute value to obtain the normalized first absolute value; and performing the nonlinear transformation on the normalized first absolute value to obtain the first fusion weight.
[0228] The performing a nonlinear transformation based on the second absolute value to obtain the second fusion weight includes: normalizing the second absolute value to obtain the normalized second absolute value; and performing the nonlinear transformation on the normalized second absolute value to obtain the second fusion weight.
[0229] It can be understood that the function used in the nonlinear transformation includes: an inverse tangent function; or an exponential function.
[0230] It can be understood that the second image is obtained based on the Y component, the second V component and the second U component, including: determining the first pixel to be corrected and the second pixel to be maintained according to the first absolute value; determining the third pixel to be corrected and the fourth pixel to be maintained according to the second absolute value; and performing pixel-by-pixel fusion based on the third U component of the first pixel, the first U component of the second pixel, the third V component of the third pixel, the first V component of the fourth pixel and the Y component to obtain the second image.
[0231] It can be understood that determining the first pixel to be corrected and the second pixel to be maintained based on the first absolute value includes: obtaining the first absolute values of different pixels in the first image and sorting them from large to small, and based on the sorting result, selecting a preset percentage of pixels with the first absolute value sorting at the front as the first pixels, and determining pixels other than the first pixels as the second pixels.
[0232] The method of determining the third pixel to be corrected and the fourth pixel to be maintained based on the second absolute value includes: obtaining a descending order of the second absolute values of different pixels in the first image, and according to the ordering result, selecting the preset percentage of pixels whose second absolute values are ranked first as the third pixels, and determining pixels other than the third pixels as the fourth pixels.
[0233] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0234] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image correction method, characterized in that: include: Acquire a first image through an image acquisition module; Obtaining a Y component, a first U component, and a first V component of the first image in a YUV space; According to the Y component, performing guided filtering on the first U component to obtain a second U component, and based on the Y component, performing guided filtering on the first V component to obtain a second V component; Based on the Y component, the second V component and the second U component, obtaining a second image includes: determining a first fusion weight according to a first absolute value of a difference between the first U component and the second U component; wherein a weight value in the first fusion weight and the first absolute value of a corresponding pixel have a nonlinear relationship; Determining a second fusion weight according to a second absolute value of a difference between the first V component and the second V component, wherein a weight value in the second fusion weight and the second absolute value of a corresponding pixel have a nonlinear relationship; Obtain a third U component according to the first fusion weight and the second U component; Obtain a third V component according to the second fusion weight and the second V component; The Y component, the third U component and the third V component are fused to obtain the second image.
2. The method according to claim 1, characterized in that: The determining a first fusion weight according to a first absolute value of a difference between the first U component and the second U component includes: Based on the first absolute value, performing a nonlinear transformation to obtain the first fusion weight; The determining a second fusion weight according to a second absolute value of a difference between the first V component and the second V component includes: Based on the second absolute value, a nonlinear transformation is performed to obtain the second fusion weight.
3. The method according to claim 2, characterized in that The performing a nonlinear transformation based on the first absolute value to obtain the first fusion weight includes: Normalizing the first absolute value to obtain the normalized first absolute value; Performing the nonlinear transformation on the normalized first absolute value to obtain the first fusion weight; The performing a nonlinear transformation based on the second absolute value to obtain the second fusion weight includes: normalizing the second absolute value to obtain the normalized second absolute value; The nonlinear transformation is performed on the normalized second absolute value to obtain the second fusion weight.
4. The method according to claim 2 or 3, characterized in that: The functions used in the nonlinear transformation include: Inverse tangent function; or, Exponential function.
5. The method according to any one of claims 1 to 3, characterized in that: The obtaining a second image based on the Y component, the second V component and the second U component includes: Determining a first pixel to be corrected and a second pixel to be maintained according to the first absolute value; determining a third pixel to be corrected and a fourth pixel to be maintained according to the second absolute value; The second image is obtained by performing pixel-by-pixel fusion based on the third U component of the first pixel, the first U component of the second pixel, the third V component of the third pixel, the first V component of the fourth pixel, and the Y component.
6. The method according to claim 5, characterized in that The step of determining the first pixel to be corrected and the second pixel to be maintained according to the first absolute value comprises: Obtaining a descending order of first absolute values of different pixels in the first image, and selecting, according to the ordering result, a preset percentage of pixels whose first absolute values are ranked first as the first pixels, and determining pixels other than the first pixels as the second pixels; The step of determining the third pixel to be corrected and the fourth pixel to be maintained according to the second absolute value comprises: Obtain a descending order of the second absolute values of different pixels in the first image, and according to the ordering result, select the preset percentage of pixels whose second absolute values are ranked first as the third pixels, and determine the pixels other than the third pixels as the fourth pixels.
7. An image correction device, characterized in that: include: An acquisition module, used for acquiring a first image through an image acquisition module; An acquisition module, used to acquire a Y component, a first U component and a first V component of the first image in a YUV space; a filtering module, configured to perform guided filtering on the first U component according to the Y component to obtain a second U component, and perform guided filtering on the first V component based on the Y component to obtain a second V component; A fusion module is used to obtain a second image based on the Y component, the second V component and the second U component, determine a first fusion weight according to a first absolute value of the difference between the first U component and the second U component; wherein there is a nonlinear relationship between the weight value in the first fusion weight and the first absolute value of the corresponding pixel; determine a second fusion weight according to a second absolute value of the difference between the first V component and the second V component; wherein there is a nonlinear relationship between the weight value in the second fusion weight and the second absolute value of the corresponding pixel; obtain a third U component according to the first fusion weight and the second U component; obtain a third V component according to the second fusion weight and the second V component; and fuse the Y component, the third U component and the third V component to obtain the second image.
8. The device according to claim 7, characterized in that The fusion module is specifically configured to perform a nonlinear transformation based on the first absolute value to obtain the first fusion weight; and perform a nonlinear transformation based on the second absolute value to obtain the second fusion weight.
9. The device according to claim 8, characterized in that The fusion module is specifically used to normalize the first absolute value to obtain the normalized first absolute value; perform the nonlinear transformation on the normalized first absolute value to obtain the first fusion weight; Normalizing the second absolute value to obtain the normalized second absolute value; performing the nonlinear transformation on the normalized second absolute value to obtain the second fusion weight.
10. The device according to claim 8 or 9, characterized in that The functions used in the nonlinear transformation include: Inverse tangent function; or, Exponential function.
11. The device according to any one of claims 7 to 10, characterized in that The fusion module is specifically used to determine a first pixel to be corrected and a second pixel to be maintained according to the first absolute value; and to determine a third pixel to be corrected and a fourth pixel to be maintained according to the second absolute value; The second image is obtained by performing pixel-by-pixel fusion based on the third U component of the first pixel, the first U component of the second pixel, the third V component of the third pixel, the first V component of the fourth pixel, and the Y component.
12. The device according to claim 11, characterized in that The fusion module is specifically used to obtain a descending order of first absolute values of different pixels in the first image, and according to the ordering result, select a preset percentage of pixels with the first absolute value ordering first as the first pixels, and determine pixels other than the first pixels as the second pixels; obtain a descending order of second absolute values of different pixels in the first image, and according to the ordering result, select a preset percentage of pixels with the second absolute value ordering first as the third pixels, and determine pixels other than the third pixels as the fourth pixels.
13. An electronic device, characterized in that: include: a memory for storing processor-executable instructions; A processor connected to the memory; The processor is configured to execute the image correction method provided in any one of claims 1 to 6.
14. A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a computer, enables the computer to perform the image correction method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image moire removing method based on direction total variation minimization and guided filtering
CN111353953A