Disclosure of Invention
In order to solve the above technical problems, an object of the present invention is to provide an image denoising method and system based on adaptive frequency domain filtering, wherein the adopted technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides an image denoising method based on adaptive frequency domain filtering, including the following steps:
converting a target image into a frequency spectrum image, and performing threshold segmentation on the frequency spectrum image to obtain a highlight interval and a plurality of filters corresponding to the highlight interval;
filtering the frequency spectrum image by using each filter to obtain a plurality of filtering frequency spectrum diagrams, acquiring the size of a tile according to the shortest distance of a highlight point pair in each filtering frequency spectrum diagram, and dividing the filtering image corresponding to the filtering frequency spectrum diagram into a plurality of tile areas;
acquiring a row sequence, a column sequence and a sequence of pixels in each tile area, and further acquiring the quantized distribution condition of the pixels in the tile area; clustering the distribution condition to obtain a plurality of categories, and obtaining the rule degree of the filtered image according to the number of the categories and the number of tile areas in each category;
and obtaining the optimal degree of the corresponding filter by utilizing the rule degree, and selecting the filter with the maximum optimal degree as an optimal filter to denoise the target image.
Preferably, the filter obtaining step includes:
and forming the highlight interval by taking a threshold value for performing threshold value segmentation on the frequency spectrum image and a maximum value of a pixel point in the frequency spectrum image as an interval endpoint, and respectively taking each value in the highlight interval as a filtering threshold value to obtain a corresponding mask as the filter.
Preferably, the process of acquiring the filtered image includes:
and converting the filtering spectrogram into a gray image, and subtracting the first gray image of the target image from the converted gray image to obtain the filtering image.
Preferably, the tile size obtaining process includes:
taking the straight line where the shortest distance is located as a reference straight line, and acquiring a first size of the reference straight line in the frequency spectrum image;
acquiring an included angle between the reference straight line and the horizontal direction, and using the included angle to pass through a central point to be used as a corresponding straight line of the reference straight line in the filtered image;
acquiring a second size of the corresponding straight line in the filtered image, and acquiring the size of a tile in the filtered image according to the proportion of the shortest distance in the first size and the second size; the tile size is inversely related to the ratio.
Preferably, after dividing the filtered image corresponding to the filtered spectrogram into a plurality of tile regions, the method further includes rotating the filtered image based on the included angle.
Preferably, the acquiring process of the distribution situation includes:
forming the row and sequence by summing each row of pixels in the tiling area respectively; obtaining the column and the sequence in the same way;
obtaining a row and a distribution according to the value and the position distribution of each element in the row and the sequence and the size of the tile; obtaining columns and distribution in the same way;
and characterizing the distribution by the row and distribution and the column and distribution composition coordinates.
Preferably, the process of obtaining the rule degree is as follows:
and calculating the ratio of the number of the tile areas to the number of the categories and the difference between the number of the tile areas in each category and the average number of the tile areas of all the categories, and weighting and summing the reciprocal of the difference and the ratio to obtain the rule degree.
Preferably, the obtaining process of the preferred degree is as follows:
and selecting the maximum value and the minimum value of the rule degrees, and calculating the preference degree according to the difference between each rule degree and the minimum value and the difference between the maximum value and the minimum value.
Preferably, the process of denoising the target image is as follows:
and obtaining the filtering spectrogram corresponding to the optimal filter, and converting the filtering spectrogram into a gray image to obtain an image obtained by denoising the target image.
In a second aspect, another embodiment of the present invention provides an image denoising system based on adaptive frequency domain filtering, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the image denoising method based on adaptive frequency domain filtering when executing the computer program.
The embodiment of the invention at least has the following beneficial effects:
filtering the frequency spectrum image by using each filter to obtain a plurality of filtering frequency spectrum diagrams, and dividing the filtering frequency spectrum diagrams into a plurality of tiles by taking the minimum distance of a highlight point pair in each filtering frequency spectrum diagram as the size of a tile; obtaining the distribution condition of pixel quantization in each tile, and clustering the distribution condition to obtain the rule degree of a filtering spectrogram; and selecting an optimal filter to denoise the image. The embodiment of the invention can adaptively select the optimal filter to denoise the image, and remove periodic texture noise as much as possible while ensuring the original texture information of the image.
Detailed Description
To further illustrate the technical means and effects of the present invention for achieving the predetermined objects, the following detailed description of the embodiments, structures, features and effects of the image denoising method and system based on adaptive frequency domain filtering according to the present invention will be made with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following describes in detail a specific scheme of the image denoising method and system based on adaptive frequency domain filtering provided by the present invention with reference to the accompanying drawings.
Referring to fig. 1, a flowchart illustrating steps of an image denoising method based on adaptive frequency domain filtering according to an embodiment of the present invention is shown, where the method includes the following steps:
step S001 converts the target image into a spectral image, and performs threshold segmentation on the spectral image to obtain a highlight section and a plurality of filters corresponding to the highlight section.
The method comprises the following specific steps:
1. graying the target image to be processed to obtain a first grayscale image as shown in fig. 2, and then performing discrete fourier transform on the first grayscale image to obtain a spectrum image as shown in fig. 3.
The horizontal and vertical coordinates of the pixel points in the frequency spectrum image reflect the frequency and the direction of the corresponding trigonometric function, and the numerical value of the pixel points represents the amplitude of the corresponding trigonometric function, namely the gray level change degree of the image on the corresponding trigonometric function.
2. And forming a highlight interval by taking a threshold value obtained by performing threshold value segmentation on the frequency spectrum image and a maximum value of a pixel point in the frequency spectrum image as an interval endpoint, and respectively taking each value in the highlight interval as a filtering threshold value to obtain a corresponding mask as a filter.
Carrying out threshold segmentation on the frequency spectrum image by utilizing a maximum inter-class variance method to obtain a self-adaptive threshold value kl of the frequency spectrum image, and selecting a maximum value P of pixel points in the frequency spectrum image max To form a highlight interval [ kl, P max ]. And regarding each value of the highlight interval as a filtering threshold yk, marking the pixel point of which the pixel value is greater than or equal to the filtering threshold yk in the frequency spectrum image as 0, otherwise, marking the pixel point as 1, and obtaining a binary mask corresponding to each filtering threshold, namely a filter corresponding to each filtering threshold.
The information filtered by different filters is different, the achieved effect is also different, and under the ideal condition, a proper filter can only filter the noise part without influencing other areas.
The degree of gray scale change of the periodic texture is severe, so that the periodic texture features are often represented as highlight points in a spectrogram. However, not all the highlights are periodic texture noise, i.e. the noise must be highlights, which is not necessarily noise. Therefore, in order to select a filter that can filter as much noise as possible without affecting the non-noise content, all values of the highlight region are respectively made to correspond to one filter, and then the optimal filter is selected.
Step S002, filtering the frequency spectrum image by using each filter to obtain a plurality of filtering frequency spectrum graphs, obtaining the size of a tile according to the shortest distance of the highlight point pair in each filtering frequency spectrum graph, and dividing the filtering image corresponding to the filtering frequency spectrum graph into a plurality of tile areas.
The method comprises the following specific steps:
1. and converting the filtering spectrogram into a gray level image, and subtracting the first gray level image of the target image from the converted gray level image to obtain a filtering image.
2. And obtaining the size of the tile according to the shortest distance of the high-brightness point pair in each filtering frequency spectrogram.
Specifically, a straight line where the shortest distance is located is used as a reference straight line, and a first size of the reference straight line in the frequency spectrum image is obtained; acquiring an included angle between a reference straight line and the horizontal direction, and taking a central point of the included angle as a corresponding straight line of the reference straight line in the filtered image; acquiring a second size of the corresponding straight line in the filtered image, and acquiring the size of the tile in the filtered image according to the proportion of the shortest distance in the first size and the second size; tile size is inversely related to scale.
The binary mask obtained after threshold segmentation only comprises highlight areas marked as 0 and background areas marked as 1, a coordinate set of edge points of connected areas of the highlight areas in the binary mask is obtained, a plurality of pairs of mutually symmetrical highlight point pairs are obtained by combining the characteristic that the filtering spectrogram is symmetrical about the center point of the image, and the distance Dd of the corresponding highlight point pairs is calculated by using a distance formula between the two points. And obtaining the shortest distance min (dd) between the highlight point pairs and the counterclockwise included angle theta of the connecting line of the highlight point pair corresponding to the shortest distance relative to the horizontal direction.
The direction of the connecting line of the highlight point pair in the spectrum image is consistent with the direction of the texture period change in the gray scale image of the corresponding space domain. And (4) passing the central point of the filtered image, taking the same included angle theta as a corresponding straight line of the straight line where the shortest distance is located in the filtered image, and acquiring the size distance TK of the corresponding straight line in the filtered image.
Further calculate the tile size WR:
wherein PK represents the length of the straight line where the shortest distance is located in the spectrum image; the epsilon is a proportion adjustment coefficient and is obtained through multiple experiments according to the actual situation.
The smaller the shortest distance of a highlight point pair in the spectral image, the larger the texture interval in the grayscale image in the corresponding spatial domain, and the larger the size of the tile. The tile size is consistent with the period frequency of the texture through the formula, so that after the tile areas are divided, the content in each tile area is more consistent, and difference comparison is carried out more accurately.
3. And dividing the filtering image corresponding to the filtering spectrogram into a plurality of tile areas, and rotating the filtering image based on the included angle.
And rotating the gray level image in the spatial domain according to the included angle theta to enable the straight line where the shortest distance is located to be horizontal or vertical so as to facilitate subsequent rule degree analysis.
Since the periodic texture belongs to the background and cannot be directly analyzed globally, the image is divided into a plurality of tile areas to determine the degree of regularity, and the size of the tile areas needs to be set according to the period frequency of the texture.
4. The rotated filtered image is divided into a plurality of tile areas according to tile size.
Each tile area is a square tile of size WR × WR, and the rotated filter image is TK, which is collectively (TK/WR) 2 A tile area.
Step S003, acquiring the row sequence, the column sequence and the sequence of the pixels in each tile area, and further acquiring the quantized distribution condition of the pixels in the tile area; and clustering the distribution situation to obtain a plurality of categories, and obtaining the rule degree of the filtered image according to the number of the categories and the number of tile areas in each category.
The method comprises the following specific steps:
1. summing each row of pixels in the tiling area to form a row and a sequence respectively; obtaining columns and sequences in the same way; obtaining the row and distribution according to the value and position distribution of each element in the row and sequence and the size of the tile; obtaining columns and distribution in the same way; and characterizing the distribution by the coordinates of the row and the column and the distribution.
Adding the pixel values of each row of pixels in the tiling area to obtain the pixel sum of the row, wherein the pixel sums of all rows form a row and sequence; the column sum sequence is obtained in the same way.
Taking the row and sequence as an example, the row and distribution is calculated from the value, position distribution, and tile size of each element in the row and sequence:
wherein, SU
i Represents the pixel sum of the ith row, i.e., the ith element in the row and sequence; WR denotes the tile size, i.e. the sequence length of the row and sequence;
the distance between the ith row and the middle row, i.e., the position distribution of the row, is shown.
The column and distribution Ly are obtained in the same way.
The coordinates (Lx, Ly) consisting of rows and columns and distributions represent the quantized distribution.
2. Clustering the distribution situation to obtain a plurality of categories, calculating the ratio of the number of tile areas to the number of the categories, calculating the difference between the number of the tile areas in each category and the average number of the tile areas of all the categories, and weighting and summing the reciprocal of the difference and the ratio to obtain the rule degree.
And clustering the distribution conditions (Lx, Ly) of all the tile areas by setting a clustering radius k, namely, the points with the distance between two coordinate points smaller than k are in the same class, and finally are clustered into an SM class, and the number of the tile areas in each class is obtained.
Calculating the rule degree gl of the filtered image:
wherein, alpha and beta respectively represent the weight of two influencing factors, sr n Indicates the number of tile areas contained in the nth class, and sj indicates the average number of tiles for all classes.
As an example, in the embodiment of the present invention, α is 0.5, and β is 0.5.
Wherein the average number of tiles
The smaller the number of categories obtained by clustering is, the more regular the image is filtered; also, the closer the number of tile regions within a category, the more regular the filtered image is crossed.
And step S004, acquiring the optimal degree of the corresponding filter by using the rule degree, and selecting the filter with the maximum optimal degree as an optimal filter to denoise the target image.
The method comprises the following specific steps:
1. the maximum value max (gl) and the minimum value min (gl) of the rule degrees are selected, and the preference degree yx is calculated according to the difference between each rule degree and the minimum value and the difference between the maximum value and the minimum value.
The specific calculation method comprises the following steps:
wherein, yx yk Indicates the preference degree of the filter, gl, at the filtering threshold yk yk Indicating the degree of regularity of the filtered image corresponding to the filter when the filtering threshold is yk.
2. And obtaining a filtering spectrogram corresponding to the optimal filter, and converting the filtering spectrogram into a gray image to obtain an image subjected to target image denoising.
Selecting a corresponding filtering threshold yk when the optimization degree yx is maximum to perform threshold segmentation on the frequency spectrum image to obtain a corresponding optimal filter, filtering the frequency spectrum image by using the filter, and performing inverse Fourier transform on the filtered frequency spectrum image to obtain a restored gray image, wherein the gray image is the image without texture noise.
In summary, in the embodiment of the present invention, the target image is converted into the spectral image, and the spectral image is subjected to threshold segmentation to obtain the highlight region and the multiple filters corresponding to the highlight region; filtering the frequency spectrum image by using each filter to obtain a plurality of filtering frequency spectrum images, acquiring the size of a tile according to the shortest distance of a highlight point pair in each filtering frequency spectrum image, and dividing the filtering image corresponding to the filtering frequency spectrum image into a plurality of tile areas; acquiring a row sequence, a column sequence and a sequence of pixels in each tiling region, and further acquiring the quantized distribution condition of the pixels in the tiling region; clustering the distribution situation to obtain a plurality of categories, and obtaining the rule degree of the filtered image according to the number of the categories and the number of tile areas in each category; and obtaining the optimal degree of the corresponding filter by utilizing the rule degree, and selecting the filter with the maximum optimal degree as an optimal filter to denoise the target image. The embodiment of the invention can adaptively select the optimal filter to denoise the image, and remove periodic texture noise as much as possible while ensuring the original texture information of the image.
The embodiment of the invention also provides an image denoising system based on adaptive frequency domain filtering, which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the processor realizes the steps of the method when executing the computer program. Since the image denoising method based on the adaptive frequency domain filtering is described in detail above, it is not described again.
It should be noted that: the sequence of the above embodiments of the present invention is only for description, and does not represent the advantages or disadvantages of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.