1. Introduction
Images are inevitably affected by noise during the process of acquisition, storage, recording, and transmission, which reduces the image contrast and seriously affects the application of images [
1]. For most images, the noise mainly comes from Gaussian noise and impulse noise. In many cases, the two types of noise appear at the same time. Gaussian noise comes from electronic circuit noise and sensor noise caused by low lighting or high temperature. It has the characteristics of high density and a wide fluctuation range of noise intensity [
2]. Impulse noise is also called salt and pepper noise, which is generated by the image sensor, transmission channel, decoder, etc., and appears as black and white spots on the image. In the process of image denoising, the main factor to be considered is to ensure the integrity of image features while removing noise. These features mainly include the information of image edge, image contour, image texture, and image color, etc.
Traditional filtering algorithms are mainly divided into two categories: spatial domain and frequency domain [
3]. The spatial domain method processes the image pixels directly, and traditional spatial filtering includes median filtering, mean filtering, Gaussian filtering, and bilateral filtering. The frequency domain method transforms the original image into the frequency domain through integral transformation, then deals with the image in the frequency domain and finally transforms it into the spatial domain inversely to enhance the image and achieve the purpose of denoising. Traditional frequency domain filtering includes Fourier transform, discrete cosine transform, wavelet transform, and multi-scale geometric analysis, etc.
Among all the algorithms for removing salt and pepper noise in images, traditional median filtering is a commonly used and effective method. The algorithm uses the median value of pixels in the neighborhood of a small window to replace the gray value of each pixel in the original image, which has a good effect on suppressing impulse noise. The image edge and other details can be better maintained. The disadvantage is that the algorithm uses the neighborhood median to replace all pixels of the noise image, which makes the algorithm’s filtering performance drop sharply under the condition of high-density noise pollution, and even loses its denoising performance, and the edges are prone to shift and the texture details are not clear. For this reason, some improved median filtering algorithms [
4,
5,
6,
7,
8] have been proposed. These algorithms improve the performance of median filtering to a certain extent and can filter out salt and pepper noise with high density; however, the protection of image edge details is still not ideal. Reference [
9] is an improved Adaptive Median Filter (AMF) algorithm, which can adjust the size of the filter window according to the noise density, but it is easy to misjudge the extreme point as a noise point to filtering. Reference [
10] is another improved adaptive median filtering algorithm. Based on the idea of maximum–minimum median filtering, the algorithm uses a two-level detection method to accurately divide pixels into signal points and noise points, so as to filtering image noise effectively. Reference [
11] proposed an improved multilevel median filtering algorithm (VHWR). The algorithm can better maintain the image details, greatly improve the filtering effect of salt and pepper noise with high density. However, the denoising effect is not satisfactory when the noise density is too high.
Since Donoho et al. proposed the hard threshold function [
12] and the soft threshold function [
13], the wavelet threshold denoising algorithm has been widely used. However, the discontinuity of the hard threshold function will cause the reconstructed image signal to oscillate, and the fixed deviation of the soft threshold function will result in blurry or excessively smooth borders to the denoised image. A large number of scholars have proposed many improved wavelet threshold functions to achieve a more accurate denoising effect [
14,
15,
16,
17,
18,
19]. Reference [
20] proposed a new wavelet threshold algorithm that overcomes the problems of fixed deviation and discontinuity in the traditional wavelet threshold function, and improves the wavelet threshold function and the threshold. Reference [
21] combines the advantages of the joint regularization restoration method of spatial local threshold processing and wavelet domain processing and can achieve good results in effectively suppressing noise and artifacts. Reference [
22] takes advantage of the merits of traditional Wiener filtering in the wavelet domain to deal with mixed noise, and it carries out improved Wiener filtering based on multi-directional weighting, so that the algorithm can well maintain the detailed features of the original image and further improve the peak signal-to-noise ratio of the output image. Reference [
23] has studied the multi-resolution method of Haar wavelet transform for medical image denoising. It applies Haar transform to each two-dimensional image layer separately and evaluates the whole image using three-dimensional technology. This method benefits from the similarity between adjacent image layers and has a reasonable denoising effect. Reference [
24] proposed a wavelet denoising method based on an unsupervised learning model. The method uses the advantages of wavelet transform and uses an unsupervised dictionary learning algorithm to create a dictionary for noise reduction, which shows very competitive denoising performance. Reference [
25] presented improvements in image gap restoration through the incorporation of edge-based directional interpolation within multi-scale pyramid transforms and reconstructed two types of image edges. Reference [
26] shows how to design a complex wavelet with good characteristics based on the important characteristics of dual-tree complex wavelet transform and explains a series of applications of dual-tree complex wavelet in signal and image processing.
Buades et al. [
27] proposed the Non-local Means (NLM) denoising algorithm in 2005. By utilizing the repeatability and self-correlation within an image, the algorithm first calculates the weighted average value of the neighborhood of all pixels in the image and the neighborhood of the current pixel, then takes the average value as the Euclidean distance between the two points and assigns weights to them through the weight function. The sum of the product of the weight and all pixels is the denoised value of the current pixel. However, the NLM algorithm still has an unsatisfactory denoising effect on excessively high noise; therefore, many new algorithms have been proposed [
28,
29,
30,
31,
32,
33]. Reference [
34] separates noise components from image information using Principal Component Analysis (PCA), improves the accuracy of similarity measurement of NLM algorithm, and achieves a good denoising effect. Reference [
35] proposes a new NLM algorithm based on similarity confirmation. The algorithm first determines the threshold according to the distance distribution between image blocks, and it then uses the reserved image blocks to realize denoising. Reference [
36] designed a new similarity weight function using the residual image information in the method noise and achieved good denoising effect. Reference [
37] uses an improved NLM algorithm to solve the problems of long time-consuming, unreasonable weight distribution and failure to highlight the role of central pixels when calculating the similarity between neighborhoods by Euclidean distance. The algorithm can measure the neighborhood similarity more accurately and better retain the edge and detail information of the image when removing Gaussian noise. The denoising effect of noised images is further improved. In recent years, denoising algorithms based on sparse regularization have attracted the attention of many scholars due to their characteristics of over-completeness and sparsity. Elad et al. [
38] proposed a denoising algorithm of sparse representation KSVD, which makes full use of the advantages of sparse representation and can well preserve the edge of the image while denoising. The algorithm assumes that the structural elements of the image can be expressed by a set of super-complete dictionary atoms. The dictionary atoms are used to reconstruct the image to remove redundancy and achieve the purpose of denoising. However, the algorithm is only suitable for removing slightly polluted noise images. In the case of serious noise pollution, the image denoising effect is not very satisfactory. In order to further improve the denoising effect, reference [
39] proposed a Non-locally Centralized Sparse Representation (NCSR) algorithm. The algorithm introduces the concept of sparse coding noise to transform the solution target of the model from acquiring the original image to suppressing the sparse coding noise of the image, and it makes full use of the nonlocal self-similarity of the image to obtain a good estimate of the sparse coding coefficient of the original image. The algorithm can still achieve a good denoising effect when the noise pollution is serious. Reference [
40] proposed a denoising algorithm, OCTOBOS, which can adaptively learn the structured incomplete sparse transform with block sparsity (or the equivalent union of square sparse transform), and cluster the data through sparse coding at the same time. Reference [
41] proposed a Trilateral Weighted Sparse Coding (TWSC) scheme for real image denoising. TWSC introduces three weight matrices into the data and regularization terms of the sparse coding framework to describe the statistical characteristics of the real noise and image prior model, and it uses the alternating direction method of multiplier to solve the problem. TWSC also has a reasonable denoising performance. Although the denoising effect is good, the iteration and updating of dictionary learning lead to a large amount of calculation and high time cost. Considering the above problems, Dabov et al. [
42] proposed a more efficient and higher sparsity transform domain sparse expression method, namely Block Matching and 3D Filtering (BM3D). BM3D utilizes the correlation between “blocks” to achieve a high degree of sparseness of images through joint filtering, with better denoising performance, higher operating efficiency, and more advantages than other methods.
Due to the development of convex and non-convex optimization methods, matrix low-rank approximation has also attracted the attention of many scholars, and many important models and algorithms have been proposed. Rank minimization is one of the important research directions. Because rank minimization is an NP-hard problem [
43], it is easy to solve using the nuclear norm of the matrix as the convex relaxation optimization target of the matrix rank, and this method is called Nuclear Norm Minimization (NNM). NNM has developed rapidly, both in theory and in application. Gu et al. [
44] proposed the Weighted Nuclear Norm Minimization (WNNM) algorithm to optimize NNM, which assigns different weights to singular values with different values, that is, the larger the singular value, the larger the weight, and the larger the proportion. The algorithm is more effective in removing the noise of natural images.
In view of the mentioned problems above and the status quo of denoising algorithms, this paper proposes a new denoising algorithm for salt and pepper + Gaussian noise based on reference [
10], reference [
20], and reference [
37]. The algorithm first uses the improved median filter algorithm to denoise the original image with mixed noise, which can filter out most of the salt and pepper noise, and then performs
n-scale wavelet decomposition on the filtered image. The high-frequency components of each subsequent layer are processed by the improved wavelet threshold algorithm to achieve preliminary removal of Gaussian noise. The processed high-frequency components and unprocessed low-frequency components are then reconstructed. After that, the wavelet decomposition on the reconstructed image is performed with 1-scale, and the improved NLM algorithm is used to process the low-frequency components, which can filter out the noise information remaining in the low frequency components. At the same time, the high-frequency components continue to be processed with the improved wavelet threshold algorithm to further filter out the noise remaining in the high-frequency components. Finally, the low-frequency components and the high-frequency components are again reconstructed to obtain the final denoised image. Experimental results show that the proposed algorithm has a better denoising effect and finer detail restoration ability, both from subjective evaluation and objective evaluation metrics, compared with the algorithms mentioned above.
2. The Filtering Algorithm for Mixed Noise with Salt and Pepper + Gaussian Noise
In this section, we will introduce and analyze the proposed filtering algorithm with mixed noise in detail. This algorithm involves the improvement of three sub-algorithms:
We made improvement to the traditional median filtering algorithm. Compared with the Adaptive Median Filtering (AMF) algorithm, the weighted multilevel median filtering algorithm, and the multilevel nonlinear weighted mean median filtering algorithm, the improved algorithm has better filtering effect for salt and pepper noise.
We improved the wavelet threshold denoising algorithm’s threshold function and threshold. This improved algorithm has better removal effect on Gaussian noise than the traditional hard threshold denoising, soft threshold denoising, and semi-soft threshold denoising algorithms.
We made improvements in the Euclidean distance function that measures the similarity of image blocks in the NLM algorithm, and the distance weight function between similar image blocks. The improved algorithm performs better in filtering Gaussian noise than the NLM algorithm and can better preserve the edge and detail information of the image.
The three improved sub-algorithms are combined to denoise salt and pepper + Gaussian noise according to a certain process. Experimental results show that the algorithm is robust and has excellent denoising ability and detail recovery ability.
2.1. The Improved Median Filtering Algorithm
Median filtering is a classical nonlinear filtering method. It sets the gray value of a pixel point to the median gray value of all pixels in the neighborhood window centered on the point, which is very effective for eliminating salt and pepper noise. Traditional median filtering uses a fixed-size filtering window to sorts all the pixels in the window to find the median value, and it then replaces the center pixel value of the window with the median value. Even if the window center value is not noise, it is still replaced, resulting in the details and edge of image to be blurred.
The algorithm proposed in this paper improves the traditional median filtering algorithm. All pixels of the image are accurately divided into signal points and noise points by the method of two-level detection, and only noise points are processed. The algorithm uses 3 × 3 filtering windows. If the median value of the pixels in the window is not the noise value, the center noise is replaced by the median value; otherwise, the center noise is not processed. This is carried out repeatedly with the corresponding 3 × 3 window in the whole image until there is no noise in the image or the noise cannot be filtered out with a 3 × 3 window. If there are still large noise blocks in the image, the noise points in the noise blocks are replaced by the mean value of the adjacent signal points.
The boundary pixels of the noisy image are copied and filled out for the purpose of denoising, so that the size of the noisy image is expanded from M ∗ N to (M + 2) ∗ (N + 2). When the denoising process is finished, the extra pixels can be deleted to obtain the correct image size.
2.1.1. First-Level Detection of Noise Point
Salt and pepper noise points generally represent the maximum or minimum value of the local area of the image, the positions of the contaminated pixels are randomly distributed, and the probability of positive and negative noise points is usually equal. Image noise points are often extreme points in local areas, but extreme points in local areas are not necessarily noise points. As shown in
Figure 1a, the central pixel is the maximum value of the 3 × 3 neighborhood. It differs greatly from the surrounding pixel value and can be considered as a noise point, while the central pixel value in
Figure 1b is still the maximum value. It has little difference from the surrounding pixel values and should be considered as a signal point.
Set
is the gray value of the center pixel of the 3 × 3 window and
,
and
represent, respectively, the maximum gray value and the minimum gray value of all pixels in window
. If
or
,
is marked as the possible noise point; otherwise,
is marked as the signal point. The following formula is constructed:
2.1.2. Second-Level Detection of Noise Point
As mentioned above, local extreme points are not necessarily noise points. If all local extreme points are taken as noise points for median value replacement, the details will inevitably be lost. For a natural smooth image, the pixel values of the smooth area are similar or even equal. Only at the edge of the image, or in the area with rich details, are the difference of image pixel values relatively large. According to human visual characteristics, it is more sensitive to the noise in the smooth area than the noise in the detailed area. If the possible noise point is still an extreme point in a larger window, this point is considered as a noise point. Using a larger window to judge noise points can effectively improve the accuracy of noise detection.
In this paper, a 7 × 7 window is used for secondary confirmation of possible noise points. The 7 × 7 window is marked as ; and represent the maximum value and the minimum value of window , respectively, and represents the possible noise of window . If or , then is marked as the noise point; otherwise, is marked as the signal point.
The following formula is constructed:
2.1.3. The Selection for Window Size
The selection of filtering window size will affect the filtering effect. A large window has a strong filtering ability but a weak detail preservation ability; a small window can retain many details of the image, but its filtering performance is bad. Selecting the filter window adaptively according to the size of the noise density can alleviate the contradiction between filter performance and detail preservation, but it also increases the time complexity of the algorithm.
If the median value in the 3 × 3 neighborhood window of a noise point is still noise, the filtering fails. If the neighborhood window is enlarged to 5 × 5 and the median value in the window is no longer noise, the filtering is successful after replacing the noise point with the median value. In fact, if a noise point cannot be successfully filtered using a 3 × 3 window, it can be put aside and used to process those noise points that can be successfully filtered using a 3 × 3 window. Once all noise points that can be filtered by a 3 × 3 window have been replaced with their corresponding median values, those noise points can no longer be processed before being filtered. Therefore, the filtering results of these two methods are the same. In our proposed algorithm, the size of the filtering window is selected as 3 × 3.
2.1.4. Processing of Noise Blocks
If the image is slightly polluted by noise, filtering with a 3 × 3 filtering window repeatedly can deal with all the noise. However, if the image is seriously polluted by noise, the larger noise blocks cannot be filtered by a 3 × 3 filtering window. As shown in
Figure 2, 0 represents signal point and 1 represents noise point. The experimental results show that, when the noise density is less than 0.5, all noise can be removed by repeated filtering with a 3 × 3 filtering window.
For the noise in the noise block, the algorithm deals with it with mean filtering. For the noise outside the noise block, the algorithm replaces it with the mean gray value of its adjacent pixels.
Figure 3 shows the four cases in which noise points are replaced by the mean gray values of adjacent pixels. Similarly, 1 represents noise point and 0 represents signal point.
Formula (3) shows the calculation method of noise point in the first case in
Figure 3.
2.1.5. The Implementation Process of the Algorithm
Mark all the noise points in the image. If the (i,j) pixel is a noise point, then set and replace = 0.
If , obtain the median value Med of all pixels in the 3 × 3 window centered on point (i,j); If the median value Med is not noise, replace the central pixel of the 3 × 3 window with Med, set and replace ; otherwise, the center pixel will not be processed.
Finish processing all points with and output the results as the image to be processed.
If replace , repeat steps (2) and (3); otherwise, it means that there is no noise in the image or there are large noise blocks but they cannot be processed by a 3 × 3 window.
If , it indicates that there are still noise blocks in the image, and then the noise is replaced by the mean value of the adjacent signal points.
Output the filtering results.
2.2. The Improved Wavelet Threshold Denoising Algorithm
Since Donoho et al. proposed the hard threshold function [
12] and the soft threshold function [
13], the wavelet threshold denoising algorithm has been widely used. However, the discontinuity of the hard threshold function will cause the reconstructed image signal to oscillate, and the fixed deviation of the soft threshold function will result in blurry or excessively smooth borders of the denoised image. Based on the soft and hard threshold functions, this algorithm proposes an improved threshold function that overcomes the discontinuity of hard threshold and the fixed deviation of soft threshold, reduces the compression of wavelet coefficients, and solves the problems of image oscillation and boundary blur to a certain extent. At the same time, the new threshold can change with the noise level of the high-frequency components in each layer of wavelet decomposition, which has strong flexibility and adaptability.
2.2.1. The Theory of Wavelet Threshold Denoising
Wavelet transform is a linear operation. After wavelet transform, the wavelet coefficients of noise image are equal to the sum of wavelet coefficients of the original image and the wavelet coefficients of noise. Separating noise means removing the wavelet coefficients of noise and retaining the wavelet coefficients of the original image in the wavelet domain.
After multi-scale wavelet decomposition, the wavelet coefficients of effective information of the image and the wavelet coefficients of noise have different characteristics. The part of low-frequency is wavelet approximation; the part of high-frequency is wavelet details. The effective information of image is mainly distributed in wavelet approximation; the high-frequency part mainly contains image edge and noise. The effective information of image is mainly concentrated in larger wavelet coefficients, while noise is mainly concentrated in smaller wavelet coefficients. With the increase of wavelet decomposition scale, the wavelet coefficients of the effective signal of the image become increasing larger, while the wavelet coefficients of noise information become increasing smaller. Therefore, the wavelet coefficients of the image between effective information and noise information tend to separate after repeated decomposition. According to this principle, image signal and noise signal can be separated.
Therefore, the process of wavelet threshold denoising can be summarized as follows: first decompose the original image with appropriate wavelet basis, and then select a proper threshold value to deal with noise, and finally reconstruct the wavelet coefficients to obtain an ideal denoised image.
It is very important to construct an appropriate threshold function and select a proper threshold. The threshold function commonly used is the one proposed by Donoho; the hard threshold function [
12] and the soft threshold function [
13] are shown in Formulas (4) and (5), respectively.
where
is the
k-th wavelet coefficient under the
j-th scale of noise image after wavelet decomposition;
is the wavelet coefficients obtained through threshold processing;
is the threshold selected by the algorithm; and
sign is the symbolic function.
When , the hard threshold function will not compress the wavelet coefficients, so the edges and details of the image will be preserved. When the discontinuity of the function will distort the restored image. The soft threshold function is continuous when , and the image is smoother after threshold processing. When , the wavelet coefficients will shrink to zero. There is a constant deviation between the estimated wavelet coefficients and the real wavelet coefficients, resulting in the blurred edge of the reconstructed image. Both the threshold functions can result in the loss of details and some important features of image.
2.2.2. The Improved Wavelet Threshold Function
Aiming at the discontinuity and constant deviation of the traditional threshold function, this paper proposes a new wavelet threshold function. When the new threshold function is used to process the wavelet coefficients, the wavelet coefficients after denoising are closer to the wavelet coefficients of the original image, so the distortion of the restored image is smaller.
The threshold function expression is:
where
,
, and
are adjustable parameters. When
, the function value is not directly set to 0, but is expressed as a quadratic function, which avoids the oscillation caused by the direct truncation of the threshold function and overcomes the problem of constant deviation between the wavelet coefficients of the traditional threshold function and the estimated wavelet coefficients.
The following is a mathematical analysis to the properties of the improved threshold function:
Therefore,
thus it can be seen that the improved threshold function is continuous at
λ.
Therefore, thus it can be seen that the improved threshold function is continuous at −λ.
Therefore, it is concluded that the improved threshold function is continuous at ±λ.
When
:
when
:
when
:
Thus, the asymptote of the improved threshold function is .
Therefore,
The deviation between and will gradually decrease when , which indicates that the improved threshold function overcomes the deviation of the traditional threshold function.
When , the improved threshold function is highly differentiable, which is beneficial to the subsequent mathematical processing of the function.
When and , the improved threshold function becomes the hard threshold function.
When and , the improved threshold function becomes the soft threshold function.
Because of the adjustable factors, the function can be adjusted between the soft threshold function and the hard threshold function. The reason why the wavelet coefficients at are retained instead of being set to zero is that it can deal with noise coefficients in high-frequency components more flexibly.
To sum up, by analyzing the continuity, asymptotic property, deviation, and adjustable factors of the function, it is concluded that the improved threshold function of the algorithm is continuous and high-order derivable. It solves the deviation problem and has a relatively high flexibility.
2.2.3. The Selection of Wavelet Threshold
It is important to construct a good threshold function, and it is crucial to select an appropriate threshold. The wavelet coefficient of the signal after wavelet decomposition is larger, the wavelet coefficient of the noise is smaller, and the wavelet coefficient of the noise is smaller than the wavelet coefficient of the signal. Therefore, by selecting an appropriate threshold, wavelet coefficients larger than the threshold are considered to be generated by the signal and should be retained, and wavelet coefficients smaller than the threshold are considered to be generated by noise and should be removed. This is the basic principle of wavelet threshold denoising.
If the threshold is too large, some important features of the image will be filtered out. If the threshold is too small, there will be more residual noise and the denoising effect is not ideal. Donoho proposed a general threshold [
12]:
where
represents the standard deviation of noise and
M ×
N represents the size of image.
Equation (16) is a global threshold, which is a unified threshold used for denoising the whole image. However, the local threshold can determine the threshold of each image block according to its own noise level. Compared with the global threshold, the local threshold can be adjusted according to different noise blocks, and the value is more flexible.
Noise components are mainly concentrated in the high-frequency coefficients and decrease with the increase of decomposition scale. Effective signal components are mainly concentrated in the low-frequency coefficients and increase with the increase of decomposition scale. Therefore, the threshold should gradually decrease as the decomposition scale increases.
In this algorithm, the threshold is set as:
where
is an adjustable parameter,
(
is the corresponding wavelet decomposition scale,
is the noise standard deviation, and
is defined as:
where
is the median operation,
is the median value of absolute value of the wavelet decomposition coefficient of the first layer, and 0.6745 is the adjustment coefficient of the standard deviation of Gaussian noise.
The proposed threshold can be adjusted according to the value of the current decomposition scale, so as to obtain an adaptive threshold for different decomposition scales, and the threshold meets the condition of “gradually decreasing with the increase of the decomposition scale”.
2.3. The Improved NLM Denoising Algorithm
Buades [
27] et al. proposed the Non-Local Means (NLM) denoising algorithm in 2005, which takes advantage of the repeatability and self-correlation in an image. Firstly, it calculates the weighted average value of the neighborhood of all pixels in an image and the neighborhood of the current pixel. It then takes the average value as the Euclidean distance between the two points and assigns weights to them through the weight function. Finally, the sum of the product of the weight and all pixels is the denoised value of the current pixel.
Many scholars have made improvement on the problems that exist in NLM, but as for the current research status, there still exists problems such as the running time being too long, unreasonable weight distribution, and the failure to highlight the role of central pixels when using Euclidean distance to calculate the similarity between neighborhoods.
To solve the problems mentioned above, we improved the NLM algorithm. The improved algorithm uses integral image technology to change the neighborhood similarity disposal of each pixel to the unified disposal of the whole image matrix. Moreover, it uses the accumulation of Gaussian kernel functions with different radii to increase the weight of the central pixel in the neighborhood, aiming to enhance the weight role of the central pixel in the neighborhood. Finally, the weight function to measure the similarity between neighbors is improved by the power operation of the Gaussian function. Experiment results show that the improved algorithm can significantly save the running time of the algorithm and can better retain the edge and detail information of the image after denoising, and the denoising effect is significantly improved.
2.3.1. The Improved Euclidean Distance Function
In the traditional NLM algorithm, the similarity of two pixels is calculated by using the Gaussian kernel function to calculate the Euclidean distance of the neighborhood matrix centered on the two pixels. The formula of the Gaussian kernel function is shown below:
where
is the variance of the Gaussian kernel function. The Gaussian kernel function is used mainly because the distance between each pixel in the neighborhood and the center pixel point is different, and the impact on the center point is different. The closer the distance, the greater the impact, and the farther the distance, the smaller the impact [
45]. However, there is a problem that the role of the central pixel does not pay enough attention to, so that the weight of the central point is too low when using Gaussian kernels to calculate. The ideal distance function should highlight the weight of the central pixel, and the closer to the central pixel, the greater the weight distribution, and the farther from the central pixel, the more obvious the weight drops. In that way, the similarity of the two pixels calculated will be more accurate.
The Euclidean distance function designed by the algorithm is based on the Gaussian kernel function and accumulates Gaussian kernels with different radii. The radius ranges from 1 to
r; the time of accumulation is also
r, and the size of the Gaussian kernel matrix obtained is (2
r + 1) × (2
r + 1). The calculation formula is as follows:
In order to unify the size of each Gaussian kernel matrix, the elements around the matrix with a radius less than r are filled with 0. Each Gaussian kernel calculated needs to be normalized, and the final normalization is performed after accumulation.
2.3.2. The Improved Distance Weight Function
When the similarity of two pixels, i.e., the Euclidean weighted distance of two neighboring blocks is calculated, the NLM algorithm needs to assign a corresponding weight value to the distance. The smaller the distance, the greater the similarity between the two neighboring blocks, and the greater the weight value assigned. The weight value and the distance are similar to the inverse relationship. At the same time, the weight function also requires that the weight value assigned can drop rapidly when the distance increases, and its purpose is to ignore the effect of neighboring pixels that are not similar to the current pixel structure as much as possible.
The weight function in the traditional NLM algorithm is the Gaussian function, and the weight value follows Gaussian distribution. Based on the Gaussian function, the weight function of the proposed algorithm is set as the power function of the Gaussian function (power value ). The value of power can be flexibly set according to the noise variance of the noised image and the smoothing coefficient h. In this way, the weight function is increased from one parameter (smoothing coefficient h) to two parameters (smoothing coefficient h and power value ). Although the increase of parameters increases the complexity of the algorithm to a certain extent, it also makes the distribution of weight values more flexible and accurate. Moreover, the improved weight function drops faster than the original weight function, which is more in line with the definition standard of the weight function.
The improved weight function is defined as follows:
where
is a normalized factor, which is the sum of all weights, that is, the sum is 1 after each weight and is divided by the factor. The power function of the Gaussian function corresponding to formula (21) is
.
Figure 4 shows the values of the weight function when
h = 1.2 and
= 1, 2, 3, and 4 in order to clearly reflect the comparison of function values when n takes different values.
It can be seen from
Figure 4 that the curve corresponding to
= 1 is the Gaussian function used by the original weight function, and the corresponding weight value decreases gradually with the increase of Euclidean distance. However, its weight decreases more slowly compared with the weight function curve when
= 2, 3, and 4. The larger the
value is, the faster its weight decreases. However, experiments have proved that a larger value of
n is not necessarily better; it should be considered comprehensively according to the noise level of the image, the variance
of the Gaussian kernel function, and the smoothing coefficient
h. At the same time, the running time of the algorithm should also be considered.
2.4. The Complete Process of the Proposed Algorithm
The mixed noise filtering algorithm with salt and pepper + Gaussian noise proposed in this paper is composed of the above three improved algorithms. The specific process of the algorithm is shown below:
Step 1. Input the original image and add mixed noise to the image: Density (salt and pepper noise)/Variance (Gaussian noise) = /;
Step 2. Use the improved median filter algorithm to filter the noise image and obtain the preliminary denoised image;
Step 3. Perform wavelet decomposition with n-scale on the preliminary denoised image; the selection of decomposition scale n will be explained in the experiment part.
Step 4. Use the new threshold function and the new threshold to process the high-frequency components obtained from each layer of wavelet decomposition.
Step 5. Reconstruct the high-frequency components after threshold processing and the unprocessed low-frequency components to obtain a reconstructed image1.
Step 6. Perform wavelet decomposition with 1-scale on the reconstructed image1, and then process the low-frequency components with the improved NLM algorithm to filter out the Gaussian noise remaining in the low-frequency components. At the same time, continue to perform the new wavelet threshold function to process the high frequency components.
Step 7. Reconstruct the low-frequency components and the high-frequency components that have been processed individually to obtain the reconstructed image2, which is the final denoised image.
The whole process of the proposed algorithm in this paper is shown in
Figure 5.
3. Experiment
The equipment configuration of this experiment is: Intel(R) Core(TM) I5-6200, Memory 8.00 GB, WIN10 operating system with 64-bit, and the processing software is MATLAB R2014a.
3.1. Parameter Setting
In our proposed algorithm, both the improved wavelet threshold algorithm and the improved NLM algorithm involve the setting of parameters. After adding different noise levels to different test images and comparing the experimental results repeatedly, the following parameter setting can, at present, ensure the best denoising effect.
For the improved wavelet threshold algorithm, after trying and verifying different wavelet bases and different scale values, it was finally found that when the wavelet base is sym15 and scale value n = 4, the image denoising can achieve the best effect. For the high-frequency components obtained by the wavelet decomposition of each layer, the proposed threshold function and threshold are used for denoising, with the following parameter settings: , , , and . When the reconstructed image1 is decomposed by 1-scale wavelet, the wavelet base is still sym15, and then the low-frequency components obtained by decomposition are processed by the improved NLM algorithm. In order to achieve the best filtering effect and balance the relationship with running time, the radius of the search block is set to 7 and the radius of the search window is set to 9. When calculating the Euclidean distance function, the times of accumulating the Gaussian kernels with different radius is set to 7, i.e., the parameter , the variance of the Gaussian kernel function , and when calculating the distance weight function, the smoothing coefficient h is set to 0.12 and the power value n is set to 2. Meanwhile, the high-frequency components continue to be processed through the new wavelet threshold function; , , , and is the best setting.
3.2. Experimental Results and Analysis
In order to verify the suppression effect of the algorithm in this paper on mixed noise with salt and pepper + Gaussian noise, 6 classic images were selected in the field of image processing as experimental objects to test the denoising effects and record their data. They are lena, boat, barbara, with 512 × 512 pixel; and cameraman, hill, peppers, with 256 × 256 pixel. These images are shown in
Figure 6. At the same time, those algorithms, including KSVD [
38], NCSR [
39], OCTOBOS [
40], TWSC [
41], BM3D [
42], and WNNM [
44], are introduced to compare the denoising effect with the algorithm we proposed.
During the experiment, the following salt and pepper noise density/Gaussian noise variance (/) were added to the six images used in the test algorithms: 0.03/0.01, 0.06/0.02, 0.09/0.03, 0.12/0.04, 0.15/0.05.
At the same time, some specific metrics are used, including PSNR, RMSE, SSIM, and FSIM, to evaluate the denoising effect of each algorithm. Among these metrics, the larger the PSNR, the SSIM, and the FSIM, the better the denoising effect, while the smaller the RMSE, the better the denoising effect. The values of SSIM, FSIM, and RMSE range from 0 to 1.
Table 1,
Table 2,
Table 3 and
Table 4 show PSNRs, RMSEs, SSIMs and FSIMs of the 6 images corresponding to different algorithms and different salt and pepper noise density/Gaussian noise variance (
/
). The setting of parameters in each algorithm is specified by the author in the original article.
In the tables, the optimal value of the denoising effect for each row is expressed in bold and the sub-optimal value is expressed in italics. As can be seen from the data of each metric in the four tables, the algorithm proposed in this paper has the best denoising effect among the denoised images with various noise levels, while the metric value of the BM3D algorithm is relatively high due to its strong ability to denoise Gaussian noise. The denoising effect of the BM3D algorithm is closer to the proposed algorithm when the noise level is relatively low, but as the noise increases, especially as the density of salt and pepper noise increases, its limitation in removing salt and pepper noise is highlighted. Because the extreme gray value of the salt and pepper noise point will destroy the self-similarity of image, resulting in an invalid filtering result [
46], the denoising effect is significantly reduced. However, it should be pointed out that the BM3D algorithm performs quite well in FSIM, especially when the noise level is relatively low; its FSIM value is the largest in the six test images compared with other algorithms. It fully illustrates that the block-matching mode of the BM3D algorithm is helpful for improving the feature similarity of denoised images, but when the noise level increases, the matching accuracy of similar blocks decreases. Excessive noise interferes with the feature search and block matching between blocks, so the FSIM value decreases significantly as the noise level increases. At the same time, the FSIM of our algorithm is obviously better when the noise increases, which fully shows that the algorithm has stronger denoising ability and detail restoration ability for images with serious noise interference, and the data totally demonstrates that the algorithm is very robust.
Relatively speaking, NCSR, TWSC, and WNNM also show good performance. Their metric values are relatively close, but the denoising effect of the NCSR algorithm is generally better. As described above, the KSVD algorithm has a relatively good denoising ability at low noise level, but its denoising effect decreases rapidly with the increase of noise level. Among all the algorithms, the denoising effect of OCTOBOS, relatively speaking, is the worst of the four metrics.
In order to feel the denoising effect of each algorithm on the noise images intuitively, the denoised images of lena, boat, and peppers, when
/
is 0.09/0.03, were randomly selected for comparison and analysis, and they are shown in
Figure 7,
Figure 8 and
Figure 9. At the same time,
Figure 10 shows the line charts of the lena image on PSNR, RMSE, SSIM, and FSIM with different algorithms to help us make further comparison and analysis.
From these denoised images, we can see that, for the mixed noise with salt and pepper + Gaussian noise, several other algorithms, of which KSVD and OCTOBOS are the most prominent, cannot remove the noise cleanly, except for BM3D and our algorithm, and a certain number of spots remain on the image. It also shows that these algorithms have extremely limited ability to remove mixed noise and cannot maintain the effective restoration of image detail information. Moreover, they cannot well retain image edge information. The overall picture of the denoised image is slightly rough. The BM3D algorithm can effectively remove the mixed noise, but it is still insufficient to restore the details of the image. It damages the edge of the image to a certain extent, making the edge part look fuzzy and thus losing more details, which reflects the limited ability of the BM3D algorithm to remove the mixed noise. Relatively speaking, the denoised image of our algorithm is clean. On the premise of ensuring the overall quality of the image, it can successfully remove the mixed noise and can retain the details and edge information of the image more completely. Compared with other algorithms, it has the strongest image restoration ability.
Furthermore, we can find that, from
Figure 10, PSNR, SSIM, and FSIM are steadily decreasing and RMSE is steadily increasing with the rise in noise level. The four trend lines are displayed approximately as a straight line with a low slope, which fully illustrates the robustness and stability of our algorithm. However, we still need to point out that, compared with other algorithms, our algorithm has better denoising ability, but when the noise level increases, the denoised images will inevitably show over-smoothness and a reduced ability to restore details, which is what we need to improve on in our future work.
4. Conclusions
This paper proposes a filtering algorithm for mixed noise with salt and pepper + Gaussian noise combined with the improved median filter algorithm, the improved wavelet algorithm, and the improved NLM algorithm. The algorithm makes full use of the advantages of the median filter in removing salt and pepper noise, improving the original median filter algorithm, and utilizing two-level detection to accurately divide the pixel points into signal points and noise points, which can filter salt and pepper noise effectively. In addition, the algorithm also improved the two algorithms by virtue of the good performance of wavelet threshold algorithm and NLM algorithm in filtering Gaussian noise. The improved wavelet threshold algorithm has a more scientific threshold function than the original algorithm; the improved threshold is also more reasonable, and the denoising effect is far better than the hard threshold function and the soft threshold function. The improved NLM algorithm can measure the similarity between image blocks more accurately and match similar image blocks more accurately, for the purpose of achieving a better denoising effect.
Compared with some other algorithms mentioned in this paper, the denoising effect of the proposed algorithm is the best for the mixed noise with salt and pepper + Gaussian noise, the restoration ability of image edge and detail information is the strongest, and the robustness is also the best. However, the denoised images possess the phenomenon of over-smoothness and a weakened ability to restore detail with the increase of noise level. In addition, the experimental images used in this study are standard test images in the field of image processing. How to extend this research to hyperspectral images and achieve real-time processing results in a short time will be an urgent problem that needs to be solved in the next research. At the same time, how to combine this algorithm with the latest research technologies, such as sparse representation and neural networks, to obtain a more stable and better denoising effect is also where we need to make further efforts in future work.