Image impulse noise removal method and device based on noise density
By setting the filter window according to the impulse noise density of the image and using normal pixel values to correct impulse noise pixels, the problem that median filtering cannot effectively remove dense impulse noise is solved and the image quality is improved.
Patent Information
- Application Number
- CN202410786861.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-09-10
AI Technical Summary
Existing median filtering methods cannot effectively correct pixel values when dealing with dense impulse noise, affecting image quality.
By obtaining the impulse noise density of the image, the size of the filter window is determined, and the pixel values of normal pixels are used to correct the impulse noise pixels within the filter window, and an image with impulse noise removed is output.
While reducing the amount of calculation, it effectively filters out impulse noise, retains image details, and improves the quality of the denoised image.
Smart Images

Figure CN118628393A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method and device for removing image impulse noise based on noise density, and a computer storage medium. Background Art
[0002] As the visual basis of human perception of the world, images are an important means for humans to obtain, express and transmit information. However, during the acquisition and transmission of images, due to the influence of factors such as equipment and environment, images are interfered by various signals, which in turn generates various noises. The presence of noise causes some details of the image to be lost, which not only seriously affects the visual quality of the image, but also affects its application in the field of computer vision. Therefore, it is necessary to denoise the image to improve the image quality.
[0003] There are many types of noise in images, among which Gaussian noise and impulse noise are the main parts of image noise. Therefore, if Gaussian noise and impulse noise can be effectively removed, the image quality can be greatly improved. At present, a variety of denoising methods have been proposed to remove image noise. Among them, for impulse noise, median filtering is currently commonly used to remove it. Median filtering is not only relatively simple to calculate, but also can achieve good denoising effects in most scenarios.
[0004] However, when dense impulse noise exists in an image, the existing median filtering process cannot ensure that the pixels at the impulse noise are corrected to a suitable value, thereby affecting the quality of the final output image. Summary of the invention
[0005] The purpose of the present invention is to provide a method and device for removing image impulse noise based on noise density, and a computer storage medium, so as to solve the problem of how to effectively remove impulse noise in an image.
[0006] In order to solve the above technical problems, the present invention provides an image impulse noise removal method based on noise density, comprising:
[0007] Obtain the original image and the corresponding impulse noise labeling image;
[0008] Determine the size of the filter window according to the impulse noise density;
[0009] In the filtering window, the impulse noise pixels are corrected using the pixel values of normal pixels;
[0010] Output an image with impulse noise removed.
[0011] Optionally, in the noise density-based image impulse noise removal method, the original image is a single-channel grayscale image; and the impulse noise labeling image is an impulse noise binary labeling image.
[0012] Optionally, in the image impulse noise removal method based on noise density, the method for determining the size of the filtering window according to the impulse noise density includes:
[0013] Count the impulse noise density of the entire original image;
[0014] Set the size of the filter window according to the impulse noise density.
[0015] Optionally, in the noise density-based image impulse noise removal method, the method of counting the impulse noise density of the entire original image includes:
[0016] Using the impulse noise marker map, count the number of impulse noise pixels in the entire original image;
[0017] Count the total number of pixels in the entire original image;
[0018] Calculate the impulse noise density of the entire original image, where the calculation formula is:
[0019] ρ=N n / N a
[0020] Among them, N n is the number of impulse noise pixels in the entire original image, N a is the total number of pixels of the entire original image, and ρ is the impulse noise density of the entire original image.
[0021] Optionally, in the image impulse noise removal method based on noise density, the method of setting the size of the filter window according to the impulse noise density includes:
[0022] Setting a first density threshold, a second density threshold and a third density threshold, and setting the size specifications of the filter window to include a minimum filter window, a smaller filter window, a larger filter window and a maximum filter window;
[0023] If the impulse noise density is less than the first density threshold, the filtering window is the minimum filtering window;
[0024] If the impulse noise density is greater than or equal to the first density threshold and less than the second density threshold, the filtering window is a smaller filtering window;
[0025] If the impulse noise density is greater than or equal to the second density threshold and less than the third density threshold, the filtering window is a larger filtering window;
[0026] If the impulse noise density is greater than or equal to the third density threshold, the filtering window is the maximum filtering window.
[0027] Optionally, in the noise density-based image impulse noise removal method, the first density threshold is 10%, the second density threshold is 25%, and the third density threshold is 40%.
[0028] Optionally, in the noise density-based image impulse noise removal method, the method of correcting impulse noise pixels using pixel values of normal pixels within the filtering window includes:
[0029] The current target pixel is located in the middle row and middle column of the filter window;
[0030] Using the impulse noise labeling image, determining whether the current target pixel is an impulse noise pixel;
[0031] If the current target pixel is an impulse noise pixel, the current target pixel is corrected using the pixel values of normal pixels within the filtering window.
[0032] Optionally, in the noise density-based image impulse noise removal method, the method of correcting the current target pixel using the pixel value of the normal pixel in the filtering window includes:
[0033] All pixels in the filter window are divided into normal pixels and impulse noise pixels using the impulse noise labeling map;
[0034] The pixel values of all normal pixels in the filter window are combined into an array ArrayPix;
[0035] The pixel value of the current target pixel is replaced by the median value in the array ArrayPix to correct the current target pixel.
[0036] In order to solve the above technical problems, the present invention further provides an image pulse noise removal device based on noise density, which is used to implement the image pulse noise removal method based on noise density as described in any one of the above items, and the image pulse noise removal device based on noise density includes:
[0037] An image acquisition module, used to acquire an original image and a corresponding impulse noise marker image;
[0038] A filtering and denoising module, used to determine a filtering window according to the impulse noise density, and to correct the impulse noise pixels within the filtering window using the pixel values of normal pixels;
[0039] The image output module is used to output the image with the impulse noise removed.
[0040] In order to solve the above technical problems, the present invention also provides a computer storage medium, wherein the computer storage medium stores an executable program; when the executable program is executed, the image impulse noise removal method based on noise density as described in any one of the above items is implemented.
[0041] The noise density-based image pulse noise removal method and device, and computer storage medium provided by the present invention include: obtaining an original image and a corresponding pulse noise marker; determining the size of a filter window according to the pulse noise density; correcting the pulse noise pixels using the pixel values of normal pixels within the filter window; and outputting an image with the pulse noise removed. By setting filter windows of different sizes for different pulse noise densities, it is possible to reduce the amount of calculation as much as possible while correcting the pulse noise pixels using a sufficient number of normal pixels during filtering, thereby effectively filtering out the pulse noise while retaining the details in the original image, improving the quality of the denoised image, and solving the problem of how to effectively remove the pulse noise in the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A flowchart of the method for removing image impulse noise based on noise density provided in this embodiment;
[0043] Figure 2 A data schematic diagram of an impulse noise binary labeling image under a 5×5 window provided in this embodiment;
[0044] Figure 3 A schematic diagram of an original single-channel grayscale image provided for this embodiment;
[0045] Figure 4 A schematic diagram of an image after denoising by the image impulse noise removal method based on noise density provided in this embodiment;
[0046] Figure 5 This is a schematic diagram of the structure of the image impulse noise removal device based on noise density provided in this embodiment. DETAILED DESCRIPTION
[0047] The following is a further detailed description of the image impulse noise removal method and device based on noise density and the computer storage medium proposed by the present invention in conjunction with the accompanying drawings and specific embodiments. It should be noted that the accompanying drawings are all in a very simplified form and use non-precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention. In addition, the structure shown in the accompanying drawings is often a part of the actual structure. In particular, the emphasis of each accompanying drawing is different, and sometimes different proportions are used.
[0048] It should be noted that the terms "first", "second", etc. in the specification, claims and drawings of the present invention are used to distinguish similar objects in order to describe the embodiments of the present invention, rather than to describe a specific order or sequence. It should be understood that the structures used in this way can be interchanged under appropriate circumstances. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0049] This embodiment provides a method for removing image impulse noise based on noise density. Figure 1 As shown, including:
[0050] S1, obtain the original image and the corresponding impulse noise labeling image;
[0051] S2, determine the size of the filter window according to the impulse noise density;
[0052] S3, within the filtering window, correcting the impulse noise pixel using the pixel value of the normal pixel;
[0053] S4, output the image with impulse noise removed.
[0054] The noise density-based image impulse noise removal method provided in this embodiment sets filtering windows of different sizes for different impulse noise densities, so that when filtering, the impulse noise pixels can be corrected with a sufficient number of normal pixels while reducing the amount of calculation as much as possible, thereby effectively filtering out the impulse noise while retaining the details in the original image, thereby improving the quality of the denoised image and solving the problem of how to effectively remove the impulse noise in the image.
[0055] Since a single-channel grayscale image is currently generally used to detect bright noise and dark noise during noise detection, in this embodiment, step S1 is to obtain an original image and a corresponding impulse noise label image, wherein the obtained original image may be a single-channel grayscale image, and correspondingly, the obtained impulse noise label image may be an impulse noise binary label image. Figure 2 As shown, in the impulse noise binary labeling image, the labeling value of normal pixels is 0 (which can be displayed in black in the picture), and the labeling value of impulse noise pixels is 1 (which can be displayed in white in the picture), thereby separating the impulse noise pixels from the normal pixels.
[0056] Of course, in other embodiments, original images in other formats may be used, and impulse noise markers in other marking methods may be obtained. For example, a RAW image, an RGB image, etc. may be obtained as the original image; the impulse noise marker may have different markers for bright noise and dark noise, such as setting the bright noise marker value to red, the dark noise marker value to blue, and normal pixels to white in the RGB color space.
[0057] In practical applications, in order to facilitate the one-to-one correspondence between each pixel in the original image and the impulse noise label image, the size and pixel arrangement of the original image and the impulse noise label image should be consistent.
[0058] Furthermore, in this embodiment, step S2, the method of determining the size of the filtering window according to the impulse noise density includes:
[0059] S21, counting the impulse noise density of the entire original image.
[0060] Specifically, in this embodiment, the impulse noise marker image can be used to count the number of impulse noise pixels in the entire original image; then, the total number of pixel points in the entire original image is counted; finally, the impulse noise density of the entire original image is calculated, wherein the calculation formula is:
[0061] ρ=N n / N a
[0062] Among them, N n is the number of impulse noise pixels in the entire original image, N a is the total number of pixels of the entire original image, and ρ is the impulse noise density of the entire original image.
[0063] In practical applications, a computer program can be used to count the impulse noise pixels marked in the impulse noise label map. For example, the pixels marked as 1 in the impulse noise binary label map are counted to obtain the number N of impulse noise pixels in the entire original image. n The total number of pixels can be obtained by simple pixel size calculation. For example, when the size of the entire original image is m×n pixels, the total number of pixels N a That is m×n.
[0064] S22, setting the size of the filter window according to the impulse noise density.
[0065] Specifically, in this embodiment, a first density threshold, a second density threshold, and a third density threshold are set, wherein the values of the first density threshold, the second density threshold, and the third density threshold are increased in sequence. Also, the size specifications of the filter window are set to include a minimum filter window, a smaller filter window, a larger filter window, and a maximum filter window, wherein the sizes of the minimum filter window, the smaller filter window, the larger filter window, and the maximum filter window are also increased in sequence.
[0066] Of course, in other embodiments, more density thresholds and filter windows of more sizes may be set, so that the corresponding filter windows can be more accurately matched according to the impulse noise density, thereby achieving a better filtering effect. In practical applications, it is necessary to comprehensively consider the amount of calculation and the filtering accuracy to reasonably set the density threshold and the filter window.
[0067] In order to facilitate the subsequent median filtering process, in this embodiment, the minimum filtering window, the smaller filtering window, the larger filtering window and the maximum filtering window are all square, and the number of pixels in the rows and columns are all odd numbers, so that the current target pixel to be processed is located in the center of the filtering window. Of course, in other embodiments, the size of the filtering window can also be set according to actual conditions. For example, in some cases, the filtering window can also be set to a rectangle.
[0068] In this embodiment, if the impulse noise density is less than the first density threshold, the filter window is the minimum filter window; if the impulse noise density is greater than or equal to the first density threshold and less than the second density threshold, the filter window is a smaller filter window; if the impulse noise density is greater than or equal to the second density threshold and less than the third density threshold, the filter window is a larger filter window; if the impulse noise density is greater than or equal to the third density threshold, the filter window is the maximum filter window. In this way, as the impulse noise density increases, the size of the corresponding filter window also increases, thereby ensuring that there are a sufficient number of normal pixels in the filter window for correcting the impulse noise pixels, thereby improving the accuracy of the impulse noise correction.
[0069] In a specific embodiment, the first density threshold is 10%, the second density threshold is 25%, and the third density threshold is 40%. Correspondingly, the size of the minimum filter window is 3×3, the size of the smaller filter window is 5×5, the size of the larger filter window is 7×7, and the size of the maximum filter window is 9×9. That is, in this embodiment, if ρ<10%, the size of the filter window is 3×3; if 10%≤ρ<25%, the size of the filter window is 5×5; if 25%≤ρ<40%, the size of the filter window is 7×7; if ρ≥40%, the size of the filter window is 9×9.
[0070] Of course, in practical applications, the density threshold, the size of the filter window, and the correspondence between the pulse noise density and the set multiple filter windows can be reasonably set according to the size of the original image, the density of the pulse noise in different areas of the original image, etc.
[0071] Furthermore, in this embodiment, in step S3, the method of correcting the impulse noise pixel by using the pixel value of the normal pixel in the filtering window includes:
[0072] S31, the current target pixel is located in the middle row and middle column of the filtering window.
[0073] Taking the size of the filter window as 5×5 as an example, the current target pixel is located at the 3rd row and 3rd column of the filter window. When the filter window is of other sizes, those skilled in the art can also clearly understand the actual position of the current target pixel in the filter window, and this application will not repeat it in detail.
[0074] S32: Determine whether the current target pixel is an impulse noise pixel by using the impulse noise label map.
[0075] Specifically, when the label value of a certain pixel in the impulse noise label map indicates that the pixel is an impulse noise pixel, the pixel is determined to be an impulse noise pixel. Taking the above-mentioned impulse noise binary label map as an example, if the label value corresponding to the current target pixel in the impulse noise binary label map is 1, it means that the current target pixel is an impulse noise pixel, and if the label value is 0, it means that it is a normal pixel.
[0076] S33: If the current target pixel is an impulse noise pixel, the current target pixel is corrected using the pixel values of the normal pixels in the filtering window.
[0077] Specifically, in this embodiment, first, all pixels in the filter window are divided into normal pixels and impulse noise pixels using an impulse noise marker image; then, the pixel values of all normal pixels in the filter window are combined into an array ArrayPix; finally, the pixel value of the current target pixel is replaced by the median value in the array ArrayPix to correct the current target pixel.
[0078] like Figure 2 As shown, in the 5×5 filter window, each pixel is defined as P i,j , where i = 0, 1, ... 4, j = 0, 1, ... 4, then the first pixel in the upper left corner is recorded as P 0,0 , the current target pixel is P 2,2 .from Figure 2 As can be seen from the pulse noise binary marker, P 0,3 , P 0,4 , P 1,1 , P 2,2(current target pixel), P 4,2 is an impulse noise pixel, and the rest are normal pixels. At this time, the current target pixel needs to be denoised, that is, the pixel values of the normal pixels in the filter window need to be formed into an array ArrayPix, and the pixel value of the current target pixel is replaced by the median value in the array ArrayPix.
[0079] In practical applications, after the array ArrayPix is obtained, all pixel values in the array ArrayPix can be sorted in ascending order, so as to facilitate obtaining the median Med.
[0080] In this embodiment, the pixel value of the impulse noise pixel is replaced by the median pixel value of the normal pixel in the filtering window as a correction value, so that the image details can be preserved as much as possible while the impulse noise is effectively removed, thereby effectively improving the quality of the denoised image.
[0081] To prove the effectiveness of the image impulse noise removal method based on noise density provided in this embodiment, this embodiment uses the above-mentioned image impulse noise removal method based on noise density to remove impulse noise from an original single-channel grayscale image. The original single-channel grayscale image is as follows: Figure 3 As shown. Figure 3 It can be seen that the original single-channel grayscale image has many impulse noise points (obvious bright spots and dark spots that are inconsistent with the image), and these impulse noise points need to be effectively removed. After the image impulse noise removal method based on noise density provided in this embodiment is processed, the denoised image is obtained as shown in FIG. Figure 4 As shown, from Figure 4 It can be seen that Figure 3 Most of the impulse noise points in the original single-channel grayscale image have been effectively removed, and only a few impulse noise points near the edge area have not been removed. During median filtering, when there is an edge area in the filter window, there is a large difference in the pixel value distribution of normal pixels, which has a certain impact on the selection of the median. However, this embodiment matches filter windows of different sizes according to the impulse noise density, which can improve the removal effect of impulse noise in the edge area to a certain extent. Compared with the existing median filtering denoising method, the image impulse noise removal method based on noise density provided by this embodiment can reduce the amount of calculation as much as possible while using a sufficient number of normal pixels to correct the impulse noise pixels, so that the impulse noise can be effectively filtered out while retaining the details in the original image, improving the quality of the denoised image, and solving the problem of how to effectively remove the impulse noise in the image.
[0082] This embodiment also provides an image pulse noise removal device based on noise density, which is used to implement the image pulse noise removal method based on noise density as described above. Figure 5As shown, the image impulse noise removal device based on noise density includes:
[0083] An image acquisition module, used to acquire an original image and a corresponding impulse noise marker image;
[0084] A filtering and denoising module, used to determine a filtering window according to the impulse noise density, and to correct the impulse noise pixels within the filtering window using the pixel values of normal pixels;
[0085] The image output module is used to output the image with the impulse noise removed.
[0086] The image impulse noise removal device based on noise density provided in this embodiment sets filtering windows of different sizes for different impulse noise densities through a filtering denoising module, so that when filtering, the impulse noise pixels can be corrected with a sufficient number of normal pixels while reducing the amount of calculation as much as possible, thereby effectively filtering out the impulse noise while retaining the details in the original image, improving the quality of the denoised image and solving the problem of how to effectively remove the impulse noise in the image.
[0087] Furthermore, this embodiment further provides a computer storage medium, wherein the computer storage medium stores an executable program; when the executable program is executed, the image impulse noise removal method based on noise density as described above is implemented.
[0088] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other. In addition, the different parts between the various embodiments can also be used in combination with each other, and the present invention is not limited to this.
[0089] The noise density-based image pulse noise removal method and device, and computer storage medium provided in this embodiment include: obtaining an original image and a corresponding pulse noise marker; determining the size of a filter window according to the pulse noise density; correcting the pulse noise pixels using the pixel values of normal pixels within the filter window; and outputting an image with the pulse noise removed. By setting filter windows of different sizes for different pulse noise densities, it is possible to correct the pulse noise pixels using a sufficient number of normal pixels while minimizing the amount of calculation when filtering, thereby effectively filtering out the pulse noise while retaining the details in the original image, improving the quality of the denoised image, and solving the problem of how to effectively remove the pulse noise in the image.
[0090] The above description is only a description of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention. Any changes or modifications made by a person skilled in the art in the field of the present invention based on the above disclosure shall fall within the scope of protection of the claims.
Claims
1. A method for removing image impulse noise based on noise density, characterized in that: include: Obtain the original image and the corresponding impulse noise labeling image; Determine the size of the filter window according to the impulse noise density; In the filtering window, the impulse noise pixels are corrected using the pixel values of normal pixels; Output an image with impulse noise removed.
2. The image impulse noise removal method based on noise density according to claim 1, characterized in that: The original image is a single-channel grayscale image; the impulse noise label image is an impulse noise binary label image.
3. The image impulse noise removal method based on noise density according to claim 1, characterized in that: The method for determining the size of the filtering window according to the impulse noise density comprises: Count the impulse noise density of the entire original image; Set the size of the filter window according to the impulse noise density.
4. The image impulse noise removal method based on noise density according to claim 3 is characterized in that: The method for counting the impulse noise density of the entire original image includes: Using the impulse noise marker map, count the number of impulse noise pixels in the entire original image; Count the total number of pixels in the entire original image; Calculate the impulse noise density of the entire original image, where the calculation formula is: p=N n / N a Among them, N n is the number of impulse noise pixels in the entire original image, N a is the total number of pixels of the entire original image, and ρ is the impulse noise density of the entire original image.
5. The image impulse noise removal method based on noise density according to claim 3 is characterized in that: The method for setting the size of the filter window according to the impulse noise density comprises: Setting a first density threshold, a second density threshold and a third density threshold, and setting the size specifications of the filter window to include a minimum filter window, a smaller filter window, a larger filter window and a maximum filter window; If the impulse noise density is less than the first density threshold, the filtering window is the minimum filtering window; If the impulse noise density is greater than or equal to the first density threshold and less than the second density threshold, the filtering window is a smaller filtering window; If the impulse noise density is greater than or equal to the second density threshold and less than the third density threshold, the filtering window is a larger filtering window; If the impulse noise density is greater than or equal to the third density threshold, the filtering window is the maximum filtering window.
6. The image impulse noise removal method based on noise density according to claim 5, characterized in that: The first density threshold is 10%, the second density threshold is 25%, and the third density threshold is 40%.
7. The image impulse noise removal method based on noise density according to claim 1, characterized in that: The method for correcting impulse noise pixels by using pixel values of normal pixels within the filtering window includes: The current target pixel is located in the middle row and middle column of the filter window; Using the impulse noise labeling image, determining whether the current target pixel is an impulse noise pixel; If the current target pixel is an impulse noise pixel, the current target pixel is corrected using the pixel values of normal pixels within the filtering window.
8. The method for removing image impulse noise based on noise density according to claim 7, characterized in that: The method for correcting the current target pixel by using the pixel value of the normal pixel in the filtering window includes: All pixels in the filter window are divided into normal pixels and impulse noise pixels using the impulse noise labeling map; The pixel values of all normal pixels in the filter window are combined into an array ArrayPix; The pixel value of the current target pixel is replaced by the median value in the array ArrayPix to correct the current target pixel.
9. A device for removing image impulse noise based on noise density, used to implement the method for removing image impulse noise based on noise density as claimed in any one of claims 1 to 8, characterized in that: The image impulse noise removal device based on noise density comprises: An image acquisition module, used to acquire an original image and a corresponding impulse noise marker image; A filtering and denoising module, used to determine a filtering window according to the impulse noise density, and to correct the impulse noise pixels within the filtering window using the pixel values of normal pixels; The image output module is used to output the image with the impulse noise removed.
10. A computer storage medium, characterized in that: The computer storage medium stores an executable program; when the executable program is executed, the image impulse noise removal method based on noise density as described in any one of claims 1 to 8 is implemented.
