Image denoising method and system and medium
Through the combination of lateral filtering and longitudinal gradient extraction, the mask and weighted map are calculated and weighted addition is performed, which solves the problem of noise removal at the horizontal edges in the image, and realizes efficient denoising of the image and maintaining edge sharpness.
Patent Information
- Application Number
- CN202411728063.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-21
AI Technical Summary
The prior art is difficult to effectively remove periodic noise at horizontal edges in an image, especially when maintaining image edge sharpness and gentle area information.
The transverse high-frequency signal of the image is removed by transverse filtering, combined with longitudinal gradient extraction and oblique edge detection, the mask and weight map are calculated, and weighted addition is performed to remove noise at the horizontal edge.
It realizes that while maintaining the sharpness of the image edge, periodic noise at the horizontal edge is effectively removed, improving the sharpness of the image and the accuracy of the calculation results.
Smart Images

Figure CN119671895A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image denoising method, system and medium. Background Art
[0002] Due to the process differences of image sensors and the interference of the actual application environment, the linear array camera will inevitably introduce noise when collecting images, resulting in periodic differences in pixels of different columns of the collected digital images, that is, the image has periodic lateral noise, which is particularly obvious at the horizontal edges, seriously affecting the perception of the image and the post-processing process, such as Figure 1 shown.
[0003] Digital image filtering is one of the commonly used techniques in image denoising. The main image filtering algorithms for denoising include traditional algorithms such as mean filtering, Gaussian filtering, and median filtering. The above traditional algorithms perform isotropic filtering on the entire image. Although this can suppress this noise and filter out effective high-frequency information in flat areas, it will blur the edges at the same time, resulting in poor image processing results.
[0004] Therefore, some studies have proposed edge-preserving filtering algorithms, mainly including bilateral filtering and guided filtering algorithms, which can smooth flat areas and remove noise while maintaining edges. For example, patent CN 118537252 A discloses an infrared image processing method and an infrared image processing device. This patent removes vertical lines from the image while maintaining the clarity of the edge of the image and reducing the occurrence of edge ghosting, thereby improving the clarity and accuracy of the image. Due to the "edge-preserving" characteristics of the edge-preserving filtering algorithm, this type of algorithm cannot handle noise at the edge, that is, it cannot solve the technical problem proposed in this solution. Summary of the invention
[0005] The present invention provides an image denoising method and system, which can solve at least one of the above technical problems.
[0006] To achieve the above object, the present invention proposes the following technical solutions: An image denoising method, comprising: The original image is obtained, and there is column periodic noise on the horizontal edge of the original image; Filtering the original image, filtering out the horizontal high-frequency signal of the original image, and obtaining a horizontal filtered image; Using the longitudinal gradient operator, the longitudinal gradient of the original image or the transverse filtered image is extracted to obtain the edge map; Detect the oblique edge of the edge map and obtain the oblique edge gradient value; set the mask coefficient and calculate the mask based on the oblique edge gradient value; calculate the weight map based on the mask and the edge map; wherein the mask coefficient is a positive number and the weight is not greater than 1; Based on the weight map, the lateral filtered image and the original image are weightedly added to obtain a result image.
[0007] Furthermore, filtering the original image includes: using horizontal mean filtering or horizontal Gaussian filtering to filter out horizontal high-frequency signals in the original image and eliminate periodic differences between horizontal pixel data.
[0008] Furthermore, the mask is calculated, including: determining whether the absolute value of the oblique edge gradient value of any pixel point and the product of the mask coefficient are less than 1; if less than 1, indicating that the pixel point is a non-oblique edge pixel point, then the difference between the product of the absolute value of the oblique edge gradient value of the pixel point and the mask coefficient and 1 is the mask of the pixel point, and the mask is a positive number; otherwise, it indicates that the pixel point is an oblique edge pixel point, and the mask of the oblique edge pixel point is 0.
[0009] Further, the weight map is calculated, including: if the product of the absolute value of the pixel value of any pixel point in the edge map and the mask is not greater than 1, then the product is used as the weight of the pixel point; otherwise, the weight of any pixel point in the weight map is 1.
[0010] Furthermore, the longitudinal gradient operator includes one or more of a difference operator, a Sobel operator, and a Prewitt operator.
[0011] Furthermore, detecting the oblique edge of the edge map includes: using one or more of a horizontal difference operator, a horizontal Sobel operator, and a horizontal Prewitt operator to detect the oblique edge of the edge map, and obtaining the oblique edge gradient value corresponding to any pixel point.
[0012] Furthermore, if the original image is a color image, the method further includes: performing denoising processing on the pixel data of each channel to obtain a result image of each channel. Based on the same inventive concept, the present invention also proposes an image denoising system, comprising: An acquisition module acquires an original image, wherein the horizontal edge of the original image has column periodic noise; A transverse filtering module is used to filter the original image, remove the transverse high-frequency signal of the original image, and obtain a transverse filtered image; The edge map module uses a longitudinal gradient operator to extract the longitudinal gradient of the original image or the transverse filtered image to obtain the edge map; The weight module detects the oblique edge of the original image or edge map and obtains the oblique edge gradient value; sets the mask coefficient and calculates the mask based on the oblique edge gradient value; calculates the weight map based on the mask and edge map, and the weight is not greater than 1; The weighting module performs weighted addition of the lateral filtered image and the original image based on the weight map to obtain a result image.
[0013] Furthermore, it also includes: The color processing unit performs denoising on the pixel data of each channel respectively to obtain the result image of each channel if the original image is a color image.
[0014] The present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the above-mentioned image denoising method.
[0015] The present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the image denoising method as described above is implemented.
[0016] The beneficial effects of the present invention are as follows: The image denoising method disclosed in the present invention sets a corresponding lateral filtering operator for the column periodic noise of the horizontal edge in combination with the distribution periodicity of the noise to eliminate the periodic differences between the lateral pixels; at the same time, sets the longitudinal gradient extraction and mask calculation to reduce the influence of the lateral filtering on the vertical edge, the oblique edge and the flat area, so as to improve the accuracy of the calculation result of the method.
[0017] In addition, based on the horizontal filtering process, this method further extracts the vertical gradient and calculates the weight map to measure the possibility of the pixel being at the horizontal edge. Using the weight map, the filtered image and the original image are weightedly fused to smoothly remove the periodic noise at the horizontal edge, which not only maintains the sharpness of the horizontal edge, but also does not affect the pixels in other areas, and achieves a high degree of retention of information in other areas such as flat areas, vertical edges, and oblique edges.
[0018] In addition, the method also proposes to extract the longitudinal gradient of the original image and calculate the weight map through relevant calculations; this process and the transverse filtering process both belong to the processing of the original image and can be calculated in parallel to further improve the calculation efficiency.
[0019] Compared with the existing edge-preserving filtering algorithms, in which bilateral filtering requires exponential operations and guided filtering requires complex operations such as calculating the mean, variance and covariance of each sliding window of two images, the denoising method proposed in the present invention only requires horizontal filtering, vertical gradient extraction, oblique edge detection, three simple convolution operations and point-by-point operations on the original image. The calculation is simple and fast, and there is no division operation. It is easier to deploy in embedded devices such as FPGA, is easy to implement and has low implementation cost, and has good economy. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 is the original image of Example 1 of the present invention; Figure 2 is a flow chart of the method of embodiment 1 of the present invention; Figure 3 is the edge map obtained by using the Sobel operator in Example 1 of the present invention; Figure 4 is the weight graph in Embodiment 1 of the present invention; Figure 5 is the denoising result image of Example 1 of the present invention; Figure 6 is a flow chart of the method of embodiment 2 of the present invention; Figure 7 It is a flow chart of the method of embodiment 3 of the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0022] In the image denoising method disclosed in the present invention, the horizontal and vertical directions are used to indicate the relative position relationship, and the horizontal edge and the vertical edge are used to indicate the relative position relationship, but they do not limit the edge position in the image. Example 1
[0023] like Figure 2 As shown, the present invention proposes an image denoising method, comprising: like Figure 1 As shown, the original image I(x,y) is obtained, and there is a column periodic noise on the horizontal edge of the original image. Where (x,y) is the coordinate of any pixel point.
[0024] Filter the original image, filter out the horizontal high-frequency signal of the original image, and obtain the horizontal filtered image I ave (x, y). Specifically, it includes: using horizontal mean filtering or horizontal Gaussian filtering to filter out the horizontal high-frequency signal of the original image and eliminate the periodic difference between horizontal pixel data.
[0025] If the periodic difference between the horizontal pixels at the horizontal edge position of the original image is the difference between the pixel data in each A column, the corresponding horizontal filtering operator is set to filter out the horizontal high-frequency signal and eliminate the periodic difference between the horizontal pixels.
[0026] In this embodiment, the periodic difference between the horizontal pixels at the horizontal edge position of the original image is the difference between odd and even columns, so the horizontal mean filter operator [0.5 0.5] is used to filter the original image to obtain a horizontal mean filter result image, that is, a horizontal filtered image.
[0027] The horizontal mean filter operator filters out the horizontal high-frequency information of the original image, so that the horizontal filtered image filters out the periodic noise of the odd and even columns at the horizontal edge, and eliminates the difference between the odd and even columns in the horizontal direction. However, it blurs the vertical edge at the same time.
[0028] The longitudinal gradient operator is used to extract the longitudinal gradient T(x,y) of the original image or the transverse filtered image to obtain the edge map. The longitudinal gradient operator includes one or more of a differential operator, a Sobel operator, and a Prewitt operator.
[0029] The Sobel operator has the following advantages: the Sobel operator performs weighted calculation on the pixel position, which can make the horizontal edge positioning more accurate; at the same time, the Sobel operator measures the possibility of any pixel being at the horizontal edge, making the calculation result more accurate.
[0030] In this embodiment, the Sobel operator is used to extract the horizontal mean filtering result image I ave The horizontal edge (i.e., vertical gradient) of (x, y) is obtained by taking the edge map, such as Figure 3 shown.
[0031] Detect the oblique edge of the edge map and obtain the oblique edge gradient value T xy (x,y).
[0032] Specifically, it includes: using one or more of a horizontal difference operator, a horizontal Sobel operator, and a horizontal Prewitt operator to detect the oblique edge of the edge map, and obtaining the oblique edge gradient value corresponding to any pixel point.
[0033] In this embodiment, based on the edge map, a horizontal difference operator is used to calculate the horizontal difference value of the edge map as the oblique edge gradient value to detect the existence of the oblique edge in the edge map; to reduce the impact of lateral filtering on the oblique edge area, so as to improve the accuracy of the calculation results of this method.
[0034] Preferably, one or more of a horizontal Sobel operator and a horizontal Prewitt operator may be used to detect the oblique edge of the edge map to obtain the corresponding oblique edge map.
[0035] Set the mask coefficient and calculate the mask based on the oblique edge gradient value.
[0036] Specifically, it includes: judging whether the product of the absolute value of the oblique edge gradient value of any pixel and the mask coefficient is less than 1; if it is less than 1, it indicates that the pixel is a non-oblique edge pixel, and the difference between the product of the absolute value of the oblique edge gradient value of the pixel and the mask coefficient and 1 is the mask of the pixel, and the mask is a positive number; otherwise, it indicates that the pixel is an oblique edge pixel, and the mask of the oblique edge pixel is 0. The mask coefficient is a positive number.
[0037] The calculation formula of the mask is as follows:
[0038] Where M(x,y) is the mask of any pixel, T xy (x, y) is the slope edge gradient value of the slope edge operator at any pixel point, C mask is the mask coefficient, C mask >0.
[0039] Based on this embodiment, the Sobel operator is used to extract the longitudinal gradient, and C is obtained based on experience. mask In this embodiment, set C mask =5.
[0040] Preferably, other operators are used to extract the longitudinal gradient, and the mask coefficient C corresponding to any operator is set according to experience and actual application scenarios. mask .
[0041] This embodiment reduces the influence of lateral filtering on the determination of the oblique edge position by calculating a mask, so as to improve the accuracy of the calculation result of this method.
[0042] Based on the mask and edge map, the weight map w(x,y) is calculated, and the weight is not greater than 1.
[0043] Specifically, if the product of the absolute value of the pixel value of any pixel point in the edge map and the mask is not greater than 1, the product is used as the weight of the pixel point; otherwise, the weight of any pixel point in the weight map is 1.
[0044] The calculation formula of weight is as follows:
[0045] Where w(x,y) is the weight of any pixel, T(x,y) is the longitudinal gradient of any pixel, and M(x,y) is the mask of any pixel.
[0046] In this embodiment, the Sobel operator is used to extract the longitudinal gradient. Based on the edge map, the weight of any pixel point is further calculated to obtain a weight map, such as Figure 4 shown.
[0047] The present application designs a calculation mask to detect oblique edges, thereby significantly reducing the influence of the weight map on the oblique edges and more accurately representing the position of the horizontal edge.
[0048] Based on the weight map w(x,y), weighted addition is performed on the lateral filtered image and the original image to obtain the result image I result (x,y) Figure 5 shown.
[0049] The weighted formula of the denoising result image is:
[0050] In the formula, I result (x, y) is the denoising result of any pixel, w(x, y) is the weight of any pixel, I ave (x, y) is the horizontal mean filtering result of any pixel point, and I(x, y) is the original pixel data of any pixel point.
[0051] and Figure 1 In comparison, the denoising filtering method proposed in this embodiment effectively removes the periodic noise of the odd and even columns at the horizontal edge, maintains the sharpness of the horizontal edge, and retains the information of the flat area.
[0052] In summary, C mask The smaller the value, the greater the weight, the more obvious the horizontal edge filtering effect of the resulting image, the smoother the horizontal edge, the smaller the difference between odd and even lines, but the greater the impact on the oblique edge; conversely, C mask The larger the value is, the smaller the filtering effect on the horizontal edge of the resulting image will be, and the smaller the effect on the oblique edge will be. Therefore, C should be reasonably set according to the actual usage scenario and the calculation method of the vertical gradient. mask The numerical value of . Example 2
[0053] like Figure 6 As shown, based on the first embodiment, if the original image is a color image, this embodiment further includes: If the original image is a color image, the pixel data of each channel is denoised to obtain the result image of each channel.
[0054] Taking the denoising process of pixel data of any channel as an example, it specifically includes: Filtering and processing pixel data of any channel to obtain a lateral filtered image of the pixel data of any channel; Extract the longitudinal gradient of the horizontal filter image corresponding to the channel to obtain the edge map of the channel; detect the oblique edge of the edge map, obtain the oblique edge gradient value, set the mask coefficient, and calculate the mask; calculate the weight map of the channel based on the mask and the edge map; Based on the weight map of the channel, the lateral filtered image and the pixel data of the channel are weightedly added to obtain the denoised result image of the channel. Example 3
[0055] Based on the above embodiments, this embodiment proposes a denoising method that can be calculated in parallel. Figure 7 shown.
[0056] The difference from Example 1 is that in this embodiment, a longitudinal gradient operator is used to extract the longitudinal gradient of the original image and obtain the edge map. Since this embodiment processes the original image, it can be calculated in parallel with the acquisition of the horizontal filtered image to improve the calculation efficiency.
[0057] The denoising method of this embodiment specifically includes: Get the original image; Filtering the original image to obtain a horizontal filtered image; Extract the vertical gradient of the original image to obtain the edge map; detect the oblique edge of the edge map, obtain the oblique edge gradient value, set the mask coefficient, and calculate the mask; calculate the weight map based on the mask and the edge map; Based on the weight map, the lateral filtered image and the original image are weightedly added to obtain a denoised result image.
[0058] Based on the same inventive concept, the present application also proposes an image denoising system to implement the above method, comprising: An acquisition module acquires an original image, wherein the horizontal edge of the original image has column periodic noise; A transverse filtering module is used to filter the original image, remove the transverse high-frequency signal of the original image, and obtain a transverse filtered image; The edge map module uses a longitudinal gradient operator to extract the longitudinal gradient of the original image or the transverse filtered image to obtain the edge map; The weight module detects the oblique edge of the edge map and obtains the oblique edge gradient value; sets the mask coefficient and calculates the mask based on the oblique edge gradient value; calculates the weight map based on the mask and the edge map, and the weight is not greater than 1; The weighting module performs weighted addition of the lateral filtered image and the original image based on the weight map to obtain a result image.
[0059] It also includes: a color processing unit, if the original image is a color image, respectively performs denoising processing on the pixel data of each channel to obtain the result image of each channel.
[0060] The present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the above-mentioned image denoising method.
[0061] The present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the image denoising method as described above is implemented.
[0062] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0063] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image denoising method, comprising: An original image is obtained, wherein there is column periodic noise on the horizontal edge of the original image, and the method further comprises: Filtering the original image, filtering out the horizontal high-frequency signal of the original image, and obtaining a horizontal filtered image; A longitudinal gradient operator is used to extract the longitudinal gradient of the original image or the transverse filtered image to obtain an edge map; Detect the oblique edge of the edge map and obtain the oblique edge gradient value; set the mask coefficient and calculate the mask based on the oblique edge gradient value; calculate the weight map based on the mask and the edge map; wherein the mask coefficient is a positive number and the weight is not greater than 1; Based on the weight map, the lateral filtered image and the original image are weightedly added to obtain a result image.
2. The image denoising method according to claim 1, characterized in that: The original image is filtered and processed, including: using horizontal mean filtering or horizontal Gaussian filtering to filter out horizontal high-frequency signals in the original image and eliminate periodic differences between horizontal pixel data.
3. The image denoising method according to claim 1, characterized in that: Calculating the mask includes: judging whether the absolute value of the oblique edge gradient value of any pixel point and the product of the mask coefficient are less than 1; if less than 1, it indicates that the pixel point is a non-oblique edge pixel point, then the difference between the product of the absolute value of the oblique edge gradient value of the pixel point and the mask coefficient and 1 is the mask of the pixel point, and the mask is a positive number; otherwise, it indicates that the pixel point is an oblique edge pixel point, and the mask of the oblique edge pixel point is 0.
4. The image denoising method according to claim 1, characterized in that: Calculating the weight map includes: if the product of the absolute value of the pixel value of any pixel point in the edge map and the mask is not greater than 1, then the product is used as the weight of the pixel point; otherwise, the weight of any pixel point in the weight map is 1.
5. The image denoising method according to claim 1, characterized in that: The longitudinal gradient operator includes one or more of a difference operator, a Sobel operator, and a Prewitt operator.
6. The image denoising method according to claim 1, characterized in that: Detecting the oblique edge of the edge map includes: using one or more of a horizontal difference operator, a horizontal Sobel operator, and a horizontal Prewitt operator to detect the oblique edge of the edge map, and obtaining the oblique edge gradient value corresponding to any pixel point.
7. The image denoising method according to claim 5, characterized in that: If the original image is a color image, the method further includes: performing denoising processing on the pixel data of each channel respectively to obtain a result image of each channel.
8. An image denoising system, characterized in that: include: An acquisition module acquires an original image, wherein the horizontal edge of the original image has column periodic noise; A transverse filtering module is used to filter the original image, remove the transverse high-frequency signal of the original image, and obtain a transverse filtered image; The edge map module uses a longitudinal gradient operator to extract the longitudinal gradient of the original image or the transverse filtered image to obtain the edge map; The weight module detects the oblique edge of the original image or edge map and obtains the oblique edge gradient value; Set the mask coefficient and calculate the mask based on the oblique edge gradient value; Based on the mask and edge map, calculate the weight map, and the weight is not greater than 1; The weighting module performs weighted addition of the lateral filtered image and the original image based on the weight map to obtain a result image.
9. The image denoising system according to claim 8, characterized in that: Also includes: The color processing unit performs denoising on the pixel data of each channel respectively to obtain the result image of each channel if the original image is a color image.
10. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program is executed by a processor, an image denoising method according to any one of claims 1 to 7 is implemented.