Image Noise Removal Method Based on Improved Nonlocal Mean Algorithm

Aiming at the problem of unclear images acquired in interactive systems, an improved image processing algorithm for nonlocal mean denoising is proposed. This algorithm combines the adaptive median ﬁlter algorithm with the traditional nonlocal mean algorithm, ﬁrst adjusts the image window adaptively, selects the corresponding pixel weight, and then denoises the image, which can have a good ﬁltering eﬀect on the mixed noise. The experimental results show that, compared with the traditional nonlocal mean algorithm, the algorithm proposed in this paper has better results in the visual quality and peak signal-to-noise ratio (PSNR) of complex noise images.


Introduction
e data signal in the interactive system will be interfered by noise during the collection and transmission process. Random noise reduces image quality and conceals detailed feature information, which is not conducive to further analysis of feature recognition and target tracking. To improve the image quality of the interactive system and ensure the accuracy of the interaction, the current denoising algorithm needs to be optimized [1,2]. Hassouni et al. removed image noise based on the HOS sequence. e motion trajectories are obtained recursively by a region-recursive estimation method [3]. Many scholars have designed detection methods for extracting image edges from noisy images [4,5]. At present, in the image denoising problem of interactive systems, most of the research is to denoise a single type of noise. However, mixed Gaussian and salt and pepper noises are common in interactive environments, so it is of great practical significance to study the problem of mixed noise filtering [6][7][8].
Denoising methods are mainly divided into three areas: spatial domain denoising, transform domain denoising, and statistical method denoising. Spatial domain noise reduction refers to the use of spatial filtering algorithms for noise reduction processing. is algorithm acts directly on the observable pixels and depends on the target pixel and neighboring pixels. Spatial filters include linear filters [9] and nonlinear filters. Common linear filtering algorithms include Wiener filtering and median filtering [10]. e disadvantage of Wiener filtering is that the image data must be smooth, so its application is limited. e median filter replaces the intermediate gray value of the target pixel with the gray value of the pixel in a certain window, which is particularly effective for removing salt and pepper noise [11]. e mean filter is a common type of nonlinear filter, which replaces the target pixel intensity with the average pixel intensity of the target neighborhood in a specific window.
ere is also a bilateral mesh denoising algorithm that can effectively filter the image [12]. e above algorithms are simple and can effectively remove the corresponding noise. However, due to the different mathematical characteristics of different noises, it is difficult for these algorithms to be effective for multiple noises at the same time, and they will all cause the edges of the image to become blurred to a certain extent. As the window increases, the image will become more blurred [13].
Nonlocal mean (NLM) algorithm is an excellent spatial denoising algorithm [14][15][16]. e algorithm uses the characteristics of many similar blocks in the image and the average value of similar blocks to suppress image noise. At the beginning, Buades et al. [17] proposed a nonlocal average denoising algorithm based on the similarity (periodicity) of image features. Before this, the periodicity of the image was mainly used for texture synthesis. In recent years, there has been a lot of research and improvement on NLM algorithm denoising methods, which are mainly used for compressed sensing, feature extraction, pattern recognition, and image denoising. With the development of mathematical theory and image processing technology, good mathematical characteristics make its denoising advantages more obvious, and this algorithm has become one of the well-known denoising algorithms.
ere are also many scholars who have improved the classic NLM algorithm, especially the steps of dividing the pixel area of the traditional algorithm, so that it can retain more image structure information [18]. For example, the patch-based NLM algorithm is used in the field of medical image recognition to improve the fidelity of the image [19]. Although the principle of NLM algorithm is simple and the denoising effect is obvious, the calculation is not simple. e main reason is that the calculation of the similarity weight is complicated and takes a lot of calculation time. erefore, how to remove pixels with little correlation while maintaining the noise reduction effect to reduce the amount of calculation will bring practical performance improvements to the NLM algorithm. e NLM algorithm has a weak filtering ability for salt and pepper noise. erefore, it is necessary to improve the NLM algorithm to make it equally effective for salt and pepper noise, thereby enhancing the denoising performance and improving the image quality of the interactive system.
Aiming at some of the shortcomings of the traditional NLM algorithm, this article conducts in-depth research on it and introduces an adaptive median filtering (AMF) algorithm, and an improved NLM algorithm for the processing of mixed color noise is proposed, which is used to better denoise the image information after information fusion.

Denoising Algorithm Based on NLM Algorithm
In the process of weighted enhancement of pixels using the NLM algorithm, similar pixels are selected in a considerable range (which can be the entire image) instead of just taking a small neighborhood like traditional spatial filtering. e NLM algorithm was originally proposed for Gaussian noise, and the Gaussian noise model is Y represents the image to be processed, and X represents the original clear image.
] is the range of pixel coordinates of the image. N ∈ l 2 (Ω) is the image noise. Assume that X represents the denoising result for any pixel coordinate i � (i 1 , i 2 ) ∈ Ω. e NLM filtering result of the gray value X(i) of the pixel is the weighted average of the gray values of all pixels in the noise-containing image Y. e corresponding mathematical model is as follows: (2) represents the image block centered on the pixel point i, the filter coefficient is set to 10σ, and C(i) represents the Gaussian weighted dissimilarity of the image block and the pixel. Its specific definition is as follows: K � (k 1 , k 2 )||k 1 | ≤ d, |k 2 || ≤ d is the neighborhood of the pixel coordinates with the origin as the center point and the radius d, and where G α (k) is a Gaussian kernel with a standard deviation of α. Equation (3) also satisfies Compared with other traditional spatial filtering, the NLM algorithm uses the similar periodicity of nonlocal images and does not have strict requirements on image characteristics. It can be seen from equation (2) that the range of its calculation search box is an entire image in the defined interval Ω, and the 21 * 21 rectangular window has the highest efficiency after testing. From the measure of dissimilarity in equation (3), the NLM algorithm calculates the weight through similar regions of the image instead of a single pixel. It has been tested that 7 * 7 or 9 * 9 rectangular windows have the highest efficiency. e formula of NLM algorithm to remove noise is where h is the filter parameter and Y i , Y j is the image block 2 is the measure of dissimilarity between similar blocks of the image, where K � (k 1 , k 2 ) is the pixel neighborhood with d as the radius and the origin as the center, and G α (k) is the Gaussian kernel with standard deviation α.
Convert the digital image collected by the sensor into a grayscale image. Let X represent the original image without noise and Y represent the image containing noise.
represents the value range of 2 Complexity pixel coordinates, and the value range of image gray is [l min , l max ]. N is Gaussian noise whose mean is 0 and the standard deviation is σ. en, the image model with Gaussian noise is e transmission of interactive images generally contains salt and pepper noise. In the salt and pepper noise model, for ∀i � (i 1 , i 2 ) ∈ Ω, where p is the intensity of salt and pepper noise. e above is the definition of Gaussian noise and impulse noise. e mixed noise model of the two noises is defined as rough research, it is found that the median filter in the spatial domain, especially the AMF, has an outstanding effect on removing salt and pepper noise. Median filtering is generally divided into one-dimensional median filtering and two-dimensional median filtering. e algorithm principle of one-dimensional median filtering is to first sort the gray values of the pixels in the neighborhood of the target pixel from large to small and then take the median value from the ranked gray values to replace the gray value of the target pixel [20].
AMF has been widely used as a classic excellent filter for filtering salt and pepper noise [21][22][23][24]. Y i represents the coordinate window of a rectangle of size L * L, and L max * L max is the maximum size of the rectangle window during the algorithm. e process steps of the AMF algorithm are shown in Algorithm 1.
From the algorithm flow chart in Figure 1, it can be found that there are two main strategies of the AMF algorithm: (1) Adaptive window adjustment strategy: it can automatically adjust the window size and automatically filter useful pixels that are not disturbed by noise in the neighborhood of the picture pixels. (2) Selective enhancement strategies: the AMF algorithm keeps the gray value of uncontaminated pixels unchanged and only enhances the pixels that may be contaminated by noise.
e principle and process of the NLM and AMF algorithms are analyzed above, and then the NLM filter will be improved, and the algorithm will be applied to interactive images to improve image quality.
In the calculation of the NLM algorithm, the weight calculation between pixels i and j is based on the measure of dissimilarity between their associated image blocks Y(i) and Y(j). For Gaussian noise, the dissimilarity satisfies the following equation: However, the dissimilarity measure of equation (10) does not hold for salt and pepper noise. To solve this problem, inspired by AMF, the calculation of this dissimilarity measure can be directly established on the image space containing non-salt and pepper noise.
First, define the spatial set of non-salt and pepper noise points in the image. Y is a noisy image, and i and j are any two pixels. Let (P min , P max ) denote the range of gray values in the image block Y i and graphic block Y j ; the non-salt and pepper noise point index space of these two image blocks is defined as follows: where K � (k 1 , k 2 )||k 1 | ≤ d, |k 2 | ≤ d represents the coordinate neighborhood of the pixel with the radius d and the origin as the center point. U K u is the index space of non-salt and pepper noise points of the entire noisy image Y.
Based on this index space, the new measure of dissimilarity between Y i and Y j is as follows: e dissimilarity measure ‖Y i − Y j ‖ 2 2,α of the classic NLM algorithm is based on all pixels in Y i and Y j , while the new dissimilarity measure is based on the non-salt and pepper noise points of the two associated image blocks. For salt and pepper noise, there is which is Equation (14) can explain that the new dissimilarity measurement method proposed above maintains a certain degree of consistency between the noisy image and the original image. is consistency is also true for Gaussian noise ‖Y i − Y j ‖ 2 2,α,u ≈ ‖Y i − Y j ‖ 2 2,α . |K u | is the number of non-salt and pepper noise point index spaces. e larger the |K u |, the stronger the Complexity consistency, and the smaller the |K u |, the weaker the consistency. To obtain an accurate dissimilarity measure, it is necessary to adjust the size of the pixel neighborhood K and then select an appropriate |K u |. Let d min and d max denote the minimum radius and maximum radius of the window area, and T is the allowable threshold of |K u |. e specific algorithm steps for obtaining w ij in the improved algorithm are shown in Algorithm 2. erefore, the final filtering result of the improved NLM algorithm is It can be seen that the calculation complexity of the NLM algorithm is mainly determined by the weight calculation method. Compared with the classic NLM algorithm, the improved NLM algorithm has the advantages that the image block size can be adjusted adaptively, the weight calculation between pixels is based on the image block measurement, and the pixel weight average is based on non-salt and pepper noise points for enhancement.

Analysis of Results
is section designs two sets of experiments. e first group compares the calibration interface diagrams with different noises in the interactive system. e second group selected a classical grayscale image and a picture collected by a camera, introduced different degrees of noise and mixed noise, and then analyzed the image quality evaluation coefficient. Finally, the analysis of experimental results proves that the improved NLM algorithm has excellent denoising performance.  Initialize and start (1) Initialize window size L � 3.
(2) Calculate the minimum, median, and maximum of pixel gray values.
(3) If the minimum value of the gray value < the median value < the maximum value, go to step 5; otherwise L � L + 2. (4) If the window size is less than the maximum value of the window, go to step 2; otherwise replace the entire gray value with the median value. (5) If the minimum gray value < gray value < maximum gray value, then the gray value can be retained in the interval; otherwise the median value is used to replace the entire gray value. is experiment is mainly used as a reference for the recognition of noisy images. Figure 2 shows the calibration interface after using different noise reduction algorithms. Figure 2 It can be clearly seen from the results in Figure 2 that the system sensing points in the image after adopting the denoising algorithm are more accurate. e improved NLM algorithm has the best effect, but it is still not obvious. Considering that the complexity of the interactive environment is changing, it is necessary to quantify the data. us, the following experiments introduce different degrees of different types of noise for comparison. Figure 3 is a denoising comparison experiment. Figure 3(a) is an ordinary grayscale image, and Lena in Figure 3(b) is a classic grayscale image. e quantified evaluation of image noise generally uses the peak signal-tonoise ratio (PSNR), and the formula is as follows:
Among them, MSE � (1/|Ω|) i∈Ω (X(i) − X(i)) 2 is the mean square error. e larger the PSNR value, the better the denoising effect. Of course, there are many performance indicators that can measure the fidelity of the image, such as brightness, contrast, and structural similarity [25]. is paper mainly uses PSNR to judge the image fidelity.
In the experiment, the denoising effects of the improved NLM algorithm, NLM algorithm, and AMF algorithm are compared. e different parameter settings of different filters in the experiment are shown in Table 1.
For the NLM algorithm, h 2 � 10σ, the radius of the image block is 3 and the radius of the search window is 8. For the improved NLM algorithm, h 2 � 10σ + 300p is better, the radius of the search window is set to 8, and a, b, and Tare set to 3, 5, and 14.
Next, the image will be polluted to different degrees, and then the denoising effects of each algorithm will be compared.
First, we introduce different degrees of salt and pepper noise to compare the effects of the two images. Table 2 shows the denoising effect data of Lena images polluted by different salt and pepper noises. Table 3 shows the denoising effect data of ordinary human images polluted by different salt and pepper noises. Figure 4 shows the denoising effect of Lena image polluted by salt and pepper noise. Figure 5 is a denoising effect diagram of an image of an ordinary person polluted by salt and pepper noise.
It can be seen from the above Figures 4 and 5 and Tables 2 and 3 that the improved NLM algorithm proposed in this paper has good denoising performance against salt and pepper noise in both images. e AMF algorithm is also very powerful in removing salt and pepper noise, which is not much different from the algorithm in this paper. In contrast, the NLM algorithm is not ideal for removing salt and pepper noise.
en, introduce different degrees of Gaussian noise and then compare the experiments.
From the above Figures 6 and 7 and Table 4, it can be concluded that the improved NLM algorithm has excellent filtering effect on Gaussian noise, and PSNR value and visual effect are all better than other algorithms. Although the RSNR of the proposed algorithm is slightly lower than that of the traditional NLM algorithm, the difference is not big, and the final filtering effect is not much difference.
Finally, the mixed noise is introduced into the image, and then the performance of the denoising algorithm is considered from the aspects of PSNR and visual effect. e results are as follows.
From the performance of each denoising algorithm in the above Figures 8 and 9 and Tables 5 and 6, the improved NLM algorithm proposed in this paper has obvious advantages over other filters in removing mixed noise.
Two conclusions can be drawn from the above experiments: (1) e improved NLM filtering algorithm proposed in this paper has excellent performance in both mixed noise removal and single noise removal. Both the visual effect and the PSNR have reached a good level Initialize, select any 2 pixels i and j (1) Set minimum radius d � d min (2) If d ≤ d max , calculate K u , otherwise go to step 6 (3) If j ∉ K u , go to step 6 (4) If |K u | < T, then let d � d + 1, and then go to step 2 2,α,u /h 2 )), end (6) Let W ij � 0, end ALGORITHM 2: Improved NLM algorithm weight update steps.       (2) Based on the improved NLM algorithm, the precise positioning of the interactive system calibration interface is effectively improved, and the interactive point positioning is accurate, which further proves the effectiveness of the algorithm.

Conclusion
To solve the problem of Gaussian and salt and pepper noise in the image processing stage of an interactive system, this paper proposes an improved NLM algorithm for filtering mixed noise. Compared with the traditional NLM algorithm, the improved algorithm can better remove the mixed noise in the image, significantly improve the PSNR of the image, and get a clearer image, which is more conducive to the interactive system to extract useful gesture or body information from the image. e next work will explore the algorithm for color image processing effect, and whether we can continue to improve the algorithm to reduce the time spent on image denoising to reduce the interaction delay.

Data Availability
No data were used to support this study.

Conflicts of Interest
e authors declare that they have no conflicts of interest.