On the reduction of mixed Gaussian and impulsive noise in heavily corrupted color images

In this paper, a novel approach to the mixed Gaussian and impulsive noise reduction in color images is proposed. The described denoising framework is based on the Non-Local Means (NLM) technique, which proved to efficiently suppress only the Gaussian noise. To circumvent the incapacity of the NLM filter to cope with impulsive distortions, a robust similarity measure between image patches, which is insensitive to the impact of impulsive corruption, was elaborated. To increase the effectiveness of the proposed approach, the blockwise NLM implementation was applied. However, instead of generating a stack of output images that are finally averaged, an aggregation strategy combining all weights assigned to pixels from the processing block was developed and proved to be more efficient. Based on the results of comparisons with the existing denoising schemes, it can be concluded that the novel filter yields satisfactory results when suppressing high-intensity mixed noise in color images. Using the proposed filter the image edges are well preserved and the details are retained, while impulsive noise is efficiently removed. Additionally, the computational burden is not significantly increased, compared with the classic NLM, which makes the proposed modification applicative for practical image denoising tasks.

Image enhancement is one of the most frequently explored topics in image processing and computer vision.Despite the fact that the improvement of image quality has been the object of intensive research for decades, its importance is not weakened.On the contrary, the widespread availability of inexpensive devices that enable the acquisition of visual information makes that methods of image quality enhancement are still in the sphere of active research interest.
The quality of images can be degraded during the acquisition and transmission process.It might be also affected by poor lighting and unfavorable weather conditions.In particular, noise affecting the image capture, due to small sensor size and short time of exposure, reduces the perceptual quality of visual information and impedes diverse image processing tasks.In the rich body of literature, the researchers generally focus on two types of noise models.The first one is the impulsive noise, which is caused by malfunctioning camera sensors, electromagnetic interference, aging of the storage material or transmission errors 1-3 .Basically, two models of impulsive noise are considered [4][5][6][7] .The first one is salt and pepper noise or fixed value impulse noise, in which the channel values of corrupted pixels are set to either the minimum or maximum of the dynamic range.The second, much more challenging, is the Random Valued Impulsive Noise (RVIN) noise model, in which color pixel channels may attain any random value within the available range.Color images can be also affected by impulsive noise, which is introduced deliberately forming the adversarial attacks significantly decreasing the efficiency of neural networks, which are widely used for various computer vision tasks [8][9][10] .The defense techniques, which include image denoising, have recently attracted much attention from researchers working in the field of machine learning and cybersecurity.
The second type of the most frequently encountered image distortion is due to the Gaussian noise arising during acquisition and caused by the intrinsic thermal and electronic fluctuations in camera sensors.This type of noise is evenly distributed over the image and each pixel is distorted by adding a value drawn from a zeromean Gaussian distribution denoted as Additive White Gaussian Noise (AWGN).The suppression of impulsive and Gaussian noise is extensively covered in the literature, but the reduction of their mixture is less investigated, despite being a more realistic noise model.Since the majority of the widely used denoising algorithms are constructed to exclusively suppress a single type of image contamination, attenuating mixed noise is a difficult make them capable of handling both types of disturbances simultaneously.
In this work, an efficient technique capable of suppressing the MGIN is introduced.The proposed technique examines the distances to a prespecified number of similar pixels in the central patch of the processing block and builds a cumulated measure of similarity of the compared patches.In this way, a set of pixels in a patch, which are most similar to the central one in the block, are chosen, thus limiting the risk that impulsive pixels will be used for determining the patches closeness measure.
Following the NLM blockwise processing scheme, we discard the pixels which are not among the most similar ones, assuming that they are corrupted, consequently diminishing the influence of impulsive noise.As a result, from each patch in the processing block we select a group of pixels which are most similar to the central patch and the corresponding pixels from this patch are assigned weights needed for the averaging process.As the positions of the pixels chosen in each patch of the block are changing, every corresponding pixel in the central patch, including the severely corrupted, obtains large number of weighting coefficients, allowing for its robust estimation.The core of the proposed approach is a novel measure of similarity between pixel patches which yields satisfying denoising results.
In the classic blockwise NLM algorithm, each pixel in a patch obtains its estimates which are then averaged in the final denoising step, so that the final output is the mean of a stack of images whose number is equal to the number of pixels in the image patches.In this work, a different strategy, assigning the pixel weights and aggregating them in the final processing stage, without creating separate denoised images, is adopted.Such an approach, proved more robust as the small weights assigned to dissimilar patches are practically discarded in the averaging step.Additionally, performing single weighted averaging saves memory resources as the intermediate results obtained for each position of the central patch do not need to be stored to obtain the final denoising outcome.
The comparison of the efficiency of the proposed robust approach with state-of-the-art denoising schemes confirmed its satisfying properties both in terms of objective restoration measures and visual quality.The proposed filter, due to the properties of the introduced robust measure of similarity across patches, is especially efficient when restoring heavily distorted images.The performed experiments show that setting the filter's parameters is quite intuitive and its time efficiency is comparable with the standard NLM and even lower for high noise intensity.Additional computational burden is caused mainly by the need of choosing the pixels from a patch which are most similar to the one in block center.However, in practical applications significantly larger blocks and patch sizes are needed by the NLM, which translates into higher computational efficiency.
The remainder of the paper is structured as follows.The next Section presents a brief overview of the rich body of related literature.Then, in section "Robust method of MGIN reduction" the structure of the classic NLM is described.Afterwards, the robust measure of similarity between patches is introduced and ultimately the proposed MIxed NOise Reduction (MINOR) filter is described.In section "Filtering results" the influence of the filter parameters on its denoising efficiency is analyzed and the recommendations regarding their settings are provided.Eventually, the elaborated method is compared with a set of filters intended for the suppression of MGIN and the results are summarized using the standard objective measures of image quality enhancement.Examples of the restoration results obtained with the proposed and competitive techniques allow to visually asses the merits of the proposed denoising scheme.Finally, in section "Conclusion" conclusions are drawn and prospects of improvements which can increase the effectiveness of the proposed denoising framework are outlined.

Impulsive noise removal
The most popular filtering techniques intended for the suppression of impulsive noise are based on the concept of multivariate order statistics 4,12,13 .The widely used Vector Median Filter (VMF), determines the pixel from a local neighborhood for which the sum of distances to all neighbors is minimized 14 .This filter removes effectively the impulsive pixels, however one of its drawbacks is that its output is always one of the pixels from the filtering window and when the image is distorted by MGIN, the Gaussian component is not suppressed.
To diminish the number of unnecessarily processed pixels, the concept of the weighted median 15,16 was applied and to increase the capacity of VMF to suppress the Gaussian noise the average of the cluster of most similar samples was used as filter output 17,18 .A generalization of VMF, which calculates the cumulated distances to the closest pixels belonging to the filtering window and sharpens image edges, was described in Lukac et al. 19 .The VMF was also extended using the fuzzy similarity measures for vector ordering [20][21][22][23] .A detailed study and experimental comparisons of filters based on order statistics intended for impulsive noise suppression can be found in Celebi et al. 21.
In order to prevent unnecessary processing of undistorted pixels, various switching strategies are employed.Their goal is to detect the corrupted pixels and replace them with an estimate based on the local neighborhood, while keeping the remaining ones unchanged.The switching methods often rely on the vector ordering concept and determine the corrupted pixels calculating their distance to the output of a VMF based filter [24][25][26] .To tackle the problem of impulsive noise detection, various approaches based on fuzzy logic were elaborated.In 27 , the outlier detection scheme, which compares the central pixel with its neighbors was designed.Then a weighted averaging scheme incorporating the measure of pixel impulsiveness is used to suppress the noisy pixel.A fuzzybased switching technique for impulse detection and removal builds membership functions based on local pixel similarity to its neighborhood and the results of median based filtering [28][29][30][31] .
One of the most efficient filters used for the removal of impulsive noise is the Peer Group Filter (PGF) proposed in Kenney et al. 32 .This technique calculates the distances between the central pixel of the filtering window and its neighbors, which are later sorted to find the set of the closest pixels called a peer group.Another approach is determining the number of pixels in the filtering window whose distance does not exceed a predefined threshold 33 .The peer-group based techniques were later extended, however, likewise other switching filters, they remove only outlying pixels and are not effective when dealing with mixed noise [34][35][36] .In 37 , a novel variational approach to restore color images affected by impulse noise was introduced.The key innovation lies in the adaptive weighting of a data-fidelity term within the cost function.This term, derived using statistical methods, comprises two weighting functions and statistical control parameters for noise.Then a Bayesian framework is formulated where likelihood functions are defined by a mixture model.

Gaussian noise reduction
The traditional methods of the restoration of color images contaminated with Gaussian noise are based on local averaging.The important drawback of these filters is their inability to suppress the impulsive distortions, which are treated as image structures and are preserved.
The Bilateral Filter (BF), which is highly efficient in suppressing the Gaussian noise 38 builds the weighted average of pixels belonging to a processing block, considering their topographic closeness and radiometric similarity.However, it assigns the highest value to the central pixel and when it is corrupted, the filter tends to preserve it.Similar problem affects the Anisotropic Diffusion, which calculates the differences between the central pixel of a window and its members 39 to perform the diffusion process.When the central pixel is an outlier, then all the gradient magnitudes are high and the anisotropic smoothing is terminated, which again preserves the impulses.Other approaches based on Total Variation regularization 40 , which well preserve image edges, wavelet thresholding performing the shrinkage of the corrupted wavelet coefficients [41][42][43] and fuzzy-based filters 44,45 face the same problem.
The powerful Non-local Means (NLM) technique 46,47 utilizes the image self-similarity property and the final pixel estimation is the weighted average of all pixels which form similar patterns in the patches of the processing block.As this method yields excellent denoising results, an extension based on Block-Matching and 3D filtering (BM3D) exploiting the image local sparse representation in the transform domain was proposed 7,[48][49][50] .These filters provide very satisfying results when the Gaussian noise is encountered, however, they are very sensitive to impulsive noise as the utilized similarity measures between groups of pixels (patches) are susceptible to the impact of outlying pixels and the filters tend to preserve impulsive distortions.
In 51 , a pixel-level Non-Local Self Similarity (NSS) prior was introduced, wherein similar pixels across a nonlocal region are sought.This approach is motivated by the feasibility of identifying closely matching pixels in natural images.The introduced pixel-level NSS prior allows for an accurate noise level estimation method and the development of a blind image denoising technique based on the lifting Haar transform and Wiener filtering methods.

Mixed noise reduction
The most straightforward way of dealing with mixed noise is to classify the image pixels as either corrupted by impulsive or Gaussian noise and to restore these pixels with appropriate filters.In 52 , a Support Vector Machine (SVM) classifier is used to detect the type of noise corrupting each pixel to select the median or bilateral filters which suppress the impulses and the Gaussian noise component.Similar approach based on SVM was used in 53 to choose between NLM and BM3D when enhancing images with noise simulating the distortions typically encountered in natural images.
In 54 , a switching BF was proposed to reduce the mixed noise.First, the pixels are classified, either as impulses, corrupted by Gaussian noise, or noise-free, using a median based technique and then the corrupted pixels are restored by filters, whose structures are controlled by the result of the classification step.A switching BF with a novel weighting function was also used in 55 to suppress mixed noise in color images.The reference pixel of the BF is replaced by the VMF output when an impulse is detected, otherwise the standard BF is applied.
Another approach 56 first detects the impulsive noise and replaces the corrupted pixels with the local median.In the next step all pixels are processed using a fuzzy scheme relying on the values of a modified Rank Ordered Absolute Difference, (ROAD).The ROAD statistic 57 , which determines the sum of distances between a pixel and its most similar neighbors from a filtering window, was combined with the fuzzy peer group concept in Camarena et al. 58 .The technique presented in 59 first identifies impulses using the Adaptive Median Filter (AMF) and subsequently employs a variational step to eliminate residual noise.Experimental results indicate that integrating this approach with established methods can substantially enhance their denoising effectiveness In 60 , the fuzzy peer groups were used in a two-step filter which cascades the impulse removal with fuzzy averaging, performed on the same cluster of similar pixels, which reduces the computational complexity.A fast parallel implementation of the fuzzy peer group processing was put forward in Arnal et al. 61 .
Many techniques attempt to adopt patch-based methods to deal with mixed noise.However, first the impulsive noise must be removed to enable the reduction of Gaussian noise in the subsequent denoising step.In 62 , the impulses were detected and suppressed using the the median filter and a robust variance measure and afterwards the BM3D technique was applied.Similar approach was presented in 63 where the impulses were found using Adaptive Center-Weighted Median Filter (ACWMF) 64 and the strong disturbances were replaced by AMF 65 .The Gaussian noise was then suppressed using BM3D and finally the previously detected weak impulses were removed using an inpainting method based on median filtering.In 66 , the AMF is first applied to find the impulsive pixels which are then replaced by the output of NLM, so that the remaining noise has approximately a Gaussian distribution.For the removal of remaining noisy pixels similar patches are grouped and then a low rank approximation with gradient regularization is applied to reconstruct the undistorted image.The ACWMF and AMF was also applied sequentially in 11 to remove the impulses and then a method based on Laplacian scale mixture modeling and nonlocal low-rank regularization was applied.
Another approach that extends a patch-based framework was presented in Xiao et al. 67 .In this work, impulsive outliers are removed using ACWMF or AMF, depending on the assumed impulsive noise model, and the modified version of K-SVD method 68 was applied on outlier-free pixels to finally solve an l 1 − l 0 minimization problem.In 69 , first the pixels which are likely to be affected by the impulse noise are labeled and the image is restored considering the remaining pixels solving an optimization problem whose objective function is composed of content-dependent fidelity and a nonconvex, nonlocal low-rank regularization terms.Methods based on weighted dictionary learning, with encorporated impulsive noise detection have been also presented in [70][71][72] .Mixed noise removal was also considered in the problem of restoration of blurred images, in which the impulses were again detected using AMF or ACWMF and then the image was restored using variational framework based on total variation or l 1 norm of framelet coefficients [73][74][75][76][77][78] .
All the described above approaches remove in the first stage the impulses and then smooth out the remaining pixels.The second group of filters used for the reduction of MGIN performs the denoising in a single step due to incorporated mechanisms which detect and suppress the pixels introduced by a heavy-tailed noise.The ROAD statistic, which provides the measure of pixel corruption, was integrated within the BF in 57 .The resulting Trilateral Filter (TF) efficiently removes the impulsive noise and smooths out the Gaussian component while preserving image edges and details.Interestingly, like in 55 , a weighting function with different properties as in the standard BF was adopted, which increased the denoising capabilities of the trilateral approach.Satisfying properties of the TF caused that it was used in various denoising schemes 79 , however its efficiency decreases with the noise intensity.A fuzzy technique based on self-avoiding geodesic paths exploring the local neighborhood of pixels whose cost was defined using a fuzzy similarity measure was described in Szczepanski et al. 80 .The proposed approach is able to cope with strong MGIN, however the computational complexity of this method is very high and usually a few iterations are required to obtain satisfactory denoising results.
The method proposed in 81 decomposes a noisy image into three key components: the ideal image, Gaussian noise, and a heavy-tailed part.To handle outliers and sparse coefficients within the ideal image, a spike and slab prior is applied.This approach is able to adaptively infer noise statistics from the training data without requiring adjustments to model hyper-parameters.Through extensive experimentation, the method has demonstrated remarkable effectiveness, particularly in the context of suppressing high-intensity mixed noise.
In the group of patch-based methods, many approaches that successfully extend the NLM algorithm 46 were proposed.In 82 , the distances between patches are calculated considering the impulsivity of pixels expressed through the ROAD measure.This measure is also used when obtaining the weighted average of samples in the processing block which results in better efficiency when compared with the TF 57 .The authors of 83 also used the ROAD to calculate the impulsivity of pixels and utilized the estimated pixel corruption in the construction of the fuzzy weights used in the averaging process.The methods work well for low mixed noise intensity, but fail when denoising heavily corrupted images due to the inability of ROAD to effectively detect impulses.
Another impulsiveness measure based on the median absolute deviation was utilized within the NLM framework in Xiong and Yin 84 .The NLM filter is applied twice with parameters ensuring the suppression of both impulsive and Gaussian noise.Unfortunately, this filter fails when the noise contamination is high, as the corrupted pixels tend to be preserved, otherwise the image would suffer from excessive blur.In 85 , the authors propose a NLM based procedure which first estimates the noise contamination level again using ROAD measure, then the patches from the neighborhood of the processed pixel are compared calculating a weighted sum of distances between corresponding pixels and finally the image is denoised applying a maximum likelihood estimator.Various ways of improving the efficiency of NLM were proposed in Goossens et al. 86 .Especially the influence of the choice of the weighting function on the noise smoothing efficiency was investigated.In 87 , the NLM has been combined with the region homogeneity measure, which allows to decrease the influence of impulses.Additionally, an approach exploiting the Gaussian Mixture Model whose goal was to determine the degree of similarity between image regions was used.As in the case of other approaches, this filter efficiently copes with moderate noise intensity but encounters problems when highly corrupted images need to be restored.Another restoration technique was proposed in López-Rubio 88 .In the first step the degree of pixel corruption is estimated based on Bayesian classification and then an adequate weighting of the input pixels using kernel regression framework is performed.
Recently, Convolutional Neural Networks (CNN) have been adopted to tackle the problem of image denoising.The Denoising Convolutional Neural Networks (DnCNNs), which are able to effectively exploit the global image features were used to enhance images affected by impulsive [89][90][91] and Gaussian noise 92,93 .Generally, the methods based on the DnCNNs yield very good denoising efficiency 94 .However, to achieve high performance, a time-consuming training process performed on a customized dataset is needed.What is more, the information on the noise model and an estimation of the noise intensity ratio is often required, which limits their flexibility.To alleviate this problem, various blind denoising frameworks, capable of noise suppression without prior knowledge of its distribution model were proposed 95,96 .However, their effectiveness is limited in the cases of high strength of the noise contamination.
CNNs have also increasingly received attention when addressing the problem of MGIN reduction and recently, several effective methods have been introduced 97 .In 98 , the authors propose to use two CNN models divided into two steps.The first step of the blind denoising (BdCNN) is trained to remove impulsive noise and the second one to reduce the remaining Gaussian component.Another efficient algorithm of suppressing mixed noise based on CNN, which adopts computationally efficient transfer learning approach was proposed in Islam et al. 99 .In 100 , a denoising model based on Generative Adversarial Network (DeGAN), combining generator, discriminator, and feature extractor networks was designed.
A model based on variational approach and deep learning based algorithm integrated to address mixed noise removal was proposed in Wang et al. 101 .In 102 , first a deep model was trained on mixed AWGN and RVIN and then the Pixel-shuffle Down-sampling (PD) strategy was used to adapt the obtained model to real noise.The authors of 103 proposed a convolutional blind denoising network (CBDNet) which was trained on a real-world noisy images and also on their nearly noise-free counterparts.Extensive experiments performed on various datasets demonstrated excellent performance in terms of quality metrics and subjective visual quality.
In 104 , the Multi-Stage Progressive Image Restoration Network (MPRNet) was introduced for image restoration purposes.Noteworthy performance improvements have been demonstrated by MPRNet across various datasets, with a range of image restoration challenges, including denoising, deblurring, and deraining, being effectively addressed.What sets MPRNet apart is its capacity to simultaneously handle all three types of artifacts within a unified architectural framework.
An innovative method called Noise2Void (N2V) was introduced in Krull et al. 105 .This method stands out for its unique ability to train directly on the data to be denoised, without the need for noisy image pairs or clean target images.N2V is particularly useful when dealing with images where obtaining training targets, either clean or noisy, is not feasible.While it may be intuitive to expect N2V's performance to be limited due to the lack of training information compared to other methods, its denoising capabilities remain competitive, even without prior training.Another method based on deep neural network, capable of enhancing noise corrupted images without the need of observing the clean images was presented in Lehtinen et al. 106 .
In a recent study 107 , a novel deep learning-based method for blind image restoration was introduced.This approach formulates a comprehensive Bayesian generative model to characterize the degradation process induced by noise.Subsequently, a variational inference algorithm is employed to achieve image restoration.The method's effectiveness is validated through experiments on blind image denoising, demonstrating its impressive performance.
In the work 108 , a framework called ResFormer, designed to enhance performance across a diverse range of testing image resolutions, including those not previously encountered, was presented.ResFormer works by processing replicated images of varying resolutions and introduces a scale consistency loss to promote interactive information exchange across different scales.Notably, it employs a global-local positional embedding strategy to smoothly adapt to input size variations, allowing it to effectively switch between different resolutions.
While deep learning algorithms bring many benefits in terms of the restoration quality, they also suffer from significant limitations.They require large datasets of diverse images that provides the same type of noise, preferably of similar intensity, that is later expected in the incoming data.Training and deploying deep learning models for real-time denoising often demands significant computational resources, which can be a drawback for resource-constrained applications.Additionally, deep learning methods may struggle with unusual or rare noise types that are not well-represented in the training data.Traditional methods with explicit noise models may perform better in these cases.

Structure of the non-local means filter
The structure of the proposed filtering approach is based on the NLM framework 46,109 , which can be viewed as an extension of the BF.Let X be an image consisting of color pixels x i = {x q i } , with q = 1, 2, 3 denoting the color channel, where i = 1, . . ., N is the index which describes pixels position on the image domain and N denotes their overall number.The BF assigns to each image pixel x i ∈ X , the weighted average of the RGB channel values of pixels from a processing block B i of size (2r + 1) × (2r + 1) , whose center is x i .The output y i of BF depends on the spatial and radiometric similarity between x i and the neighboring pixels belonging to B i with Z i being the normalizing factor and the weights w j,i depend on the combined spatial (topographic) and color similarity between pixels.The symbol � • � denotes the Euclidean norm in the RGB color space, ρ stands for the distance between pixels on the 2D image domain, j and i are the positions of the corresponding pixels x j , x i and σ s and σ r are smoothing parameters.With σ s → ∞ , the BF approaches the Yaroslavsky Filter 110 and for σ r → ∞ it boils down to the Gaussian convolutional smoothing.
As the BF output tends to exhibit some staircase effects, introduces false edges and is sensitive to noise, many improvements have been proposed 111 .Among them the NLM approach gained high popularity as it better captures the similarity (closeness) between the processed pixel and its surrounding neighbors.The NLM filter assumes the self-similarity of structures contained in a natural image and therefore dependence on the spatial distance in (1) is omitted.The radiometric (color) similarity is expressed in terms of local neighborhoods called patches or processing windows.
(1) Let us define a patch of pixels denoted W i and centered at x i as a set of n pixels x iv contained in a square window of size (2s + 1) × (2s + 1) , where v = 1, . . ., n , n = (2s + 1) 2 , is an index associated with the pixels as depicted in Fig. 1.The dissimilarity measure D(W j , W i ) between two patches W j and W i centered at x j and x i is defined in the construction of NLM as the sum of squared Euclidean distances between corresponding pixels from the patches being compared, as depicted in Fig. 2a.
The structure of the NLM is quite similar to that of BF formulated by (1) with the weights: w j,i = exp −D(W j , W i )/σ 2 , where σ is a smoothing parameter.The dissimilarity D(W i , W j ) can be also expressed using the Gaussian Euclidean norm, as proposed in the original definition of NLM 46 , however for small patches the Gaussian weights can be neglected.The NLM filter determines for each noisy pixel x i its estimate based on the weighted average value of all remaining pixels of the processing block B i .The weights are calculated using the similarity between the patches centered at x i and pixels x j from the processing block.Such an approach is called pixelwise.
Another possibility is to calculate the dissimilarity measure D(W j , W i ) and assign it to each pixel in the patch W i .Thus, for a pixel x iv belonging to W i , a weighted average can be built taking the corresponding pixels x jv from the patches centered at pixels x j and belonging to the processing block B i .Hence, we obtain estimates y iv of the pixels x iv , for v = 1, . . ., n , using the notation presented in Fig. 1. (2) Figure 1.Indexing of pixels inside a window W i centered at x i with radius s = 1 .The pair of pixels which are symmetric with respect to the center pixel will be denoted as x iv and x iv .For example, if v = 4 then v = 6 , if v = 1 then v = 9 and so forth.www.nature.com/scientificreports/For example, the estimate y i4 of x i4 of patch W i will be calculated considering corresponding pixels in the patches belonging to the processing block B i as presented in Fig. 3 However, a given pixel x i belongs to n patches centered at pixels belonging to the neighborhood of the pixel x i as depicted in Fig. 2b.This offers the possibility to take the weighted average of all the estimates obtained from the collection of n different blocks centered at the pixels from W i .This approach, called blockwise or patchwise, due to the aggregating process, proved to offer better denoising efficiency.Using this scheme, the filter output is defined as where the block B iv is centered at pixel x iv and v denotes the index of a pixel at a position symmetric with respect to the central pixel of the patch, (see Fig. 1).The symmetric pixel is needed due to the translations of the processing block (see Fig. 2b).In this way, the filtering output is the average of n estimates calculated for various positions of the central pixel of the blocks B iv centered at x iv whose central patch contains the pixel x i .
Yet another global way of aggregating the estimates, adopted in this paper, is to take the weighted average without building separate estimates, that have to be averaged and calculating the NLM output as Using such an approach, the role of the small weights is diminished and only the most similar patches are being considered.Such an aggregation procedure is obviously more robust to outliers, as the corresponding weights do not influence significantly the final output.It is also possible to remove from the averaging the weights smaller than a predefined thresholding value, which can be a problem when using the approach expressed in (5), as some estimates y iv could not be computed in the case when the estimate is built relying on small weights, as it is the case when outlying pixels are corrupting the image.The dissimilarity measure D(W i , W j ) expressing the closeness between patches is very sensitive to outliers, which can significantly increase its value.This leads to the preservation of pixels distorted by impulsive noise, which is one of the major drawback of the NLM design. (3) (5)  www.nature.com/scientificreports/Let us assume that the central window of the processing block B and some other one show high degree of similarity.If the noise distorts the central pixels of both windows and the impulses are of similar color, then the distance expressed by (2) will remain low, which will produce a large weight in the NLM averaging scheme causing that the corrupted central pixel of the block will be retained or slightly attenuated.If the impulsive noise distorts the central pixel of the block, the distances in (2) attain high values with the exception of the weight assigned to the central pixel, which is always equal to 1, as the NLM computes the similarity of the central patch to itself.This undesired effect can be alleviated omitting the central pixel when calculating the weighted average or assigning a robust estimate to the central weight, depending on the structure of the processing block and diminishing the tendency of NLM to preserve the outlying pixels.For example, the weight assigned to the central pixel of the block can be set to be equal to the highest weight calculated for all pixels in the block excluding the central one or it can be estimated using various statistical or heuristic procedures 112 , which however, can be computationally expensive.

Robust dissimilarity measure of patches
Let d(x ju , x iv ) = �x ju − x iv � be the Euclidean distance between pixels x ju ∈ W j and x iv ∈ W i using the notation shown in Fig. 1, ( u, v = 1, . . ., n ).Then the set of distances between a given pixel x ju and all of the pixels x iv ∈ W i can be sorted in ascending order and we obtain a sequence of distances: , where d(x ju , x i(k) ) denotes the k-smallest distance between x ju and the pixels belonging to patch W i .We propose to define the dissimilarity measure between the pixel x ju and the set of pixels contained in patch W i as If we take α = n , then we calculate, the average squared distance between a pixel x j,u from the patch W j to all pixels of W i , which is in the center of the processing block B i , taking into account all pixels injected by the noise process.The outliers belonging to the patches surely influence the dissimilarity measure, so that windows from similar image regions are assigned a high value of the average squared distance between them.If α = 1 , the dis- similarity measure is equal to the smallest distance between x j,u and pixels from W i .Such a measure would be not useful, as two similar impulses injected into patches W i and W j would cause that the dissimilarity measure is low, even in the case of windows containing very differing pixel patterns.
As the window W i is assumed to be corrupted by mixed noise, we want to remove the influence of outliers and scrutinize a limited number of pixels from W i , just considering only 1 < α < n pixels, which is a compromise allowing to neglect the effect of impulses, still being able to capture the similarity of the remaining, not so heavily disturbed pixels contained in the windows being compared.Calculation of the trimmed sum of distances to only α closest pixels has been successfully used in the construction of various filters 19 and was also applied in the detection of outliers 113 .
The dissimilarity measures defined by (7) are calculated for all pixels belonging to W j .After- wards, their values are sorted and the color pixels from W j are correspondingly ordered: R(x j(1) , where R(x j(k) , W i ) denotes the k-th value of the trimmed average of distances between the pixels from W j and the window W i .The pixels x j(k) , k ∈ (1, . . ., n) , are samples generating the nondecreasing sequence of the dissimilarity measures R(x j(k) , W i ) .As we are aware that the window W i may contain outliers, to make the dissimilarity robust, we consider only the set of 1 ≤ β ≤ n pixels x j(1) , . . ., x j(β) , which will be treated as belonging to a trimmed (pruned) window denoted as W * j .Finally, the dissimilarity measure between the windows W i and W j denoted as �(W i , W j ) is defined as The distance between patches W i and W j is calculated considering only the β pixels from W j , for which the sum of squared distances to the α closest pixels from W i is minimized.Figure 4 shows a simple example which explains the structure of the proposed dissimilarity measure between two sets of points A and B in 2D case.To determine the dissimilarity between A and B, first, for each point a i , the distances to all points of B are calculated.In the example, for a 1 , a 4 and a 8 the α = 4 closest points from set B are depicted.Then, for each point from set A the α smallest distances to points contained in B are squared and averaged.In this way, to each point a i the average of α smallest squared distances to points of B denoted as R i is assigned.These averages are sorted and the dissimilarity �(A, B) is the average of the β smallest values of R assigned to points of set A. Figure 5 presents an example which shows the way, the robust similarity measure between pixel patches is computed.First, for each pixel from W j (left) the α closest pixel intensities in W i (middle) is squared and averaged.The results are contained in the array R (right) from which β smallest values are taken to obtain �(W j , W i ) .In the example the R 4 value assigned to the pixel x j4 with intensity 6 in W j is shown, (the intensities of closest pixels in W i are displayed in bold).The pixels of W j , which correspond to the β = 5 smallest values of R, are marked with green color.Thus, the trimmed window W * j is composed of the pixels marked green with intensities 4, 2, 5, 6, 3, (x j1 , x j2 , x j3 , x j4 , x j8 ) and �(W j , W i ) is the mean of β smallest values of R:

Structure of the proposed denoising technique
The proposed filter output of the pixels within the filtering window W i will be calculated using the patchwise global scheme defined by ( 6) as ( 7) Vol www.nature.com/scientificreports/This global filtering scheme will be denoted as MINOR G .Specifically, the patchwise standard approach, as defined by Eq. ( 5), will be referenced as MINOR S .It is worth noticing that the similarity of a patch to itself: �(W i , W i ) is not equal to 0, which allows to use the weight assigned to the central pixel of the block in the averaging process, thus making the proposed approach insensitive to outliers, without sacrificing the ability to suppress the Gaussian noise component.Besides, special treatment of the central pixels of the processing blocks needed in the BF and NLM design aiming at removing isolated impulses can be omitted.As illustrated in Fig. 6, for each patch in the block centered at pixel x i a different set of pixels is chosen as belonging to the β most similar ones included in W * j , which generates a corresponding set of pixels from W i which are assigned a weighting value and then taken for the averaging process.It is worth noticing that also the impulses in W i will obtain their weights, as the set of pixels belonging to W * j is not influenced directly by the outliers.Furthermore, it is advantageous that the patterns in W j and W i do not necessarily have to perfectly align, especially in the scenario of highly corrupted images where minute details become irreversibly lost.( 9)  The application of the global averaging scheme according to Eq. ( 6) is advantageous, as the stack of images produced in the standard NLM averaging approach usually contains corrupted pixels, whose averaging leads to the creation of noise artifacts.Using the global approach, the weights originating from noisy pixels are discarded, as they are too small to influence the final averaging result.

Computational complexity
In the classical pixelwise NLM filter, the computation of weights assigned to each pixel within a processing block B, containing a total of b = (2r + 1) 2 elements, necessitates the calculation of n = (2s + 1) 2 squared Euclidean distances between the central patch and all other patches within the block, (see Eq. 2) .This distance computation constitutes the primary computational load of the NLM algorithm.The final output of the standard NLM filter at a given pixel involves additional steps, including the multiplication of weights with each pixel channel value, addition of the obtained values for each channel, and the calculation of the sums of weights, which are required for the division that provides the three channels of the color filter output.As a result, the computational complexity of the standard NLM filter applied to an image comprising N pixels is expressed as O (N • n • b) 114,115 .In the patchwise implementation, the channel values of the filter output are determined using n estimates, as described by Eq. ( 5).While the patchwise implementation is more computationally demanding, the number of required distances remains the same, and only additional processing of the weights and final averaging of the obtained n output images are required.
Regarding complexity, our proposed MINOR S filter, also adopting the patchwise approach, primarily differs in the calculation of weights.To determine a weight, we need to compute for every pixel in the central patch all distances to pixels in patches contained within the block, resulting in the computation of n • n squared Euclidean distances for each patch.Furthermore, for each pixel in the central patch, we must sort the distances to find the α smallest ones, followed by sorting the cumulated distances to find the β smallest values and corresponding pixels.Excluding the sorting, the computational complexity of the proposed robust NLM is O (N • n 2 • b) , which is n times higher than the complexity of the NLM.The MINOR G version of the new filter is faster, as all weights are multiplied with corresponding channel values and then normalized.This eliminates the need to create n separate estimates.Instead, the final output is computed as a sum of the weights multiplied by the channel intensities and then divided by the overall sum of weights, as shown in Eqs. ( 6) and (9).
It is important to note that in the proposed MINOR G approach, the required block size is significantly smaller compared to using the patchwise NLM for the same Gaussian noise intensity 109 .Consequently, even with the same level of Gaussian noise and additional impulsive noise distortion, our filter operates significantly faster and allows for real-time image processing.
Figure 7 provides a comparative analysis of the execution time for our proposed MINOR G filter, as opposed to the patchwise implementation of NLM using the parameters outlined in Table 1.The experiments were conducted using a CUDA-compatible NVIDIA RTX2080Ti graphics card, affirming the computational efficiency of our denoising approach.Notably, our proposed filter exhibits comparable or even reduced computational overhead compared to the patchwise version of NLM.This efficiency is largely attributed to the smaller processing block and patch size requirements.Processing a full HD image with a resolution of 1920×1080 takes an average of just 5 milliseconds, rendering it suitable for real-time image processing applications.
Reducing the computational complexity, which surpasses that of the NLM filter, can be achieved by employing less computationally demanding dissimilarity measures between pixels in the patches under comparison.Moreover, integrating rapid and straightforward mechanisms to estimate the level of noise corruption within a specific patch can facilitate the exclusion of heavily corrupted patches from the averaging process, resulting in a reduction of computational workload 115 .

Figure 6.
The structure of the trimmed window W * j and W * k centered at x j , x k depends on its relation to the central window W i .The green color highlights the pixels used in the averaging process, ( β = 5).

Filtering results
The experiments, whose aim was to evaluate the effectiveness of the proposed filter, were performed on a database of 100 images of resolution 640× 480 , which consists of color test images corrupted with various degrees of noise intensity.The dataset is available for download at http:// denoi sing.net and also accessible as electronic supplemental material 116 .Additionally, the widely used standard color test images WINDOW, MONARCH, PEPPERS, CAPS, MOTOCROSS and BALLOONS were chosen to perform detailed examination of the proposed filter properties, (see Fig. 8).
These images were contaminated by Gaussian noise with standard deviation σ n = p and then they were cor- rupted by uniform impulsive noise with the percentage of corrupted pixels equal to p.The distortion with parameter p = 10 means that the image was contaminated by Gaussian noise with standard deviation equal to 10 and impulsive noise with 10% of corrupted pixels.Such a mixture of the impulsive and Gaussian noise was used in our previous papers and proved to simulate well the real image distortions 117,118 .
In this work, we have chosen 3 noise degradation levels p = 10 , 30 and 50.The denoising effectiveness was assessed in terms of the Peak Signal to Noise Ratio (PSNR) defined as where �•� denotes the L 2 norm in RGB color space and o i , y i stand for the original and restored image pixels.Furthermore, the Multi-Scale Similarity Measure (MSSIM) was used to better express the image restoration quality in consistency with subjective ratings 119 .In this paper this measure is presented in a logarithmic form, to allow for a more effective analysis of the results: MSSIM L = −10 log 10 (1 − MSSIM).
To better express the ability of removing impulses, a "relaxed" mean squared error measure is used, which leads to the Impulse Removal Index (IRI) 118,120   where o j are the original (clean) pixels contained in window W i and y i is the filtering output.
The IRI enables to efficiently measure the capacity of a filter to suppress the impulsive noise as shown in Fig. 9.If the impulsive pixel x i was restored, then the minimal distance between the filter output y i and the clean pixels in the window W i is determined.If the impulse is retained, no close pixel in the window of the clean image can be found, which increases the contribution to the sum in the definition of IRI.In this way, if the output of a filter is close to one of the clean pixels from the window W i , small penalty is imposed on the IRI measure.In consequence, the IRI provides a reliable measure of impulsive noise suppression.

Influence of filter parameters
In order to determine the optimal parameter values of the proposed patchwise filtering technique with global weighting as described by Eq. ( 9), a series of comprehensive experiments was performed.Their aim was to evaluate the influence of α , β , σ , r and s on the efficiency of the denoising approach in terms of the commonly used PSNR quality measure.
The experiments on various images contaminated with different noise intensities revealed that the patch size 3×3 is sufficient to obtain satisfactory denoising results for all contamination levels and the increase of s did not improve the quality parameters or even made it worse.Therefore, we set s = 1 in all of the performed experiments.Then, we evaluated the impact of the radius r of the processing block B and the parameter α on the denoising efficiency of the proposed filter.For the analysis, exhaustive examination of all sets of parameters was performed, ( α, β ∈ [1, 9] , r ∈ [1, 15] and σ ∈ [1, 100] with step 1).
The dependence of PSNR on the radius r and α using the test image PEPPERS and BALLOONS is presented in Fig. 10.As can be observed, satisfying results were achieved for the 3×3 filtering block, ( r = 1 ) for low noise contamination ( p = 10 ).However, the size of the block must be increased when the noise is stronger.Good results are obtained when using r = 6 for filtering images corrupted with noise intensity p = 30 and r ∈ [9, 13]  is needed for p = 50 .These parameter values are consistent with those obtained using a database of 100 images.The boxplot presented in Fig. 11a confirms the values of the recommended block size r needed to achieve best possible results in terms of PSNR.
It is worth noticing that in the classic NLM algorithm, the recommended block sizes are much larger 109 .For images distorted with Gaussian noise of standard deviation σ n less than 15, the required block size is r = 10 and for those exceeding 30, the suggested r is 17.The recommended patch size is like in our algorithm s = 1 for low contamination, however it must be increased to s = 3 for moderate noise intensity ( 30 < σ n < 45 ) and even to s = 5 for very strong pollution.It can be concluded that the required block and patch sizes needed to obtain satisfying results using our technique are significantly lower that in the case of the classic NLM, which translates directly into a significant reduction of the computational burden, which is proportional to squared s and r parameter values.
The analysis of the results depicted in Figs. 10 and 11b shows that for low contaminations the parameter α should be set to 2. For higher contaminations the optimal value of α is 4. The parameter β is not significantly Figure 9.The metric IRI expresses the ability of a filter to suppress impulsive noise.If the yellow pixel in the noisy image is replaced by a pixel from the filtering window of the clean image, then the sum in Eq. ( 11) will be not increased.If the impulse in the filtered image is preserved, the sum will be considerably increased.
• Pixel-shuffle Down-sampling Denoising, (PD) 126 • Weighted KSVD, (WKSVD) 127 • Variational Image Restoration Network, (VIRNet) 107 We compared the proposed MINOR filter using the global averaging, (indicated by the subscript G -MINOR G ), according to Eq. ( 6), and using the standard blockwise implementation, (denoted as MINOR S ), which performs the averaging of a stack of n = (2s + 1) 2 images.As can be seen, the global averaging provides slightly better results in terms of PSNR for higher contaminations.However, when scrutinizing the MSSIM L and IRI measures, MINOR G performs better also for images contaminated with low intensity noise.
Upon scrutinizing the Table 2, which encapsulates the PSNR, MSSIM L , and IRI measures across a range of 23 filters, noteworthy observations emerge.Specifically, the MLSM-NLR, TF, PD, WKSVD, and BdCNNN filters demonstrate high efficiency, particularly evident in their performance with low-contamination images.However, it is noteworthy that the proposed MINOR filter consistently ranks among the top 5 methods, irrespective of the test image or the quality metric applied.Notably, when confronted with higher contamination levels, our proposed denoising approach consistently yields the most favorable objective quality measures.It notably outperforms competitive filters, particularly excelling in terms of the IRI index.
Figures 15 and 16 present a comparative analysis of filtering outcomes achieved with the BALLOONS and MONARCH test images, both contaminated by noise at an intensity level of p = 30 .The MINOR G filter, utilizing the recommended parameters, demonstrates favorable results in preserving edges and suppressing noise within homogeneous image regions.However, its limitation lies in the challenge of preserving intricate details in slightly distorted images, attributed to the design of the dissimilarity measure applied to patches, which does not account for the spatial pixel arrangement.Nevertheless, this specific design is advantageous for the restoration of heavily degraded images where fine details are typically lost.The conducted experiments demonstrate that the suggested algorithm efficiently accomplishes denoising in a single step when using the recommended parameter values.Additional denoising attempts, even with adjusted parameters α and σ , result in excessive image smoothing.However, for the highly distorted image at p = 50 , as anticipated, a second iteration effectively eliminates residual noise and enhances denoising performance.Given that the filter executes denoising in a single pass, its computational complexity is akin to methods employing local averaging, such as NLM, TF, FWNLM, and RLSF.
Figure 17 displays color error maps, showcasing the discrepancies between the restored and clean images.These error maps represent the absolute differences between corresponding color components of the compared images, each value multiplied by a factor of 10 to enhance visibility.The pixel intensity within the error map corresponds to the accuracy of color restoration, where darker regions indicate accurately recovered pixels, while brighter regions signify poorly restored pixels.The hue in these regions is indicative of the channel that was most poorly reconstructed.Furthermore, the values of the Mean Absolute Error (MAE) widely used for assessing image detail preservation, are also provided, ( o and y denote the original and denoised images).
The competitive filters often exhibit tendencies to either overly smooth noisy images or leave residual blotches and incorrectly suppressed impulses.When addressing heavily corrupted images, notably successful denoising outcomes were achieved using deep learning-based approaches, such as PD and BdCNN.Figure 17 illustrates the discernible preservation of image details and effective noise suppression in smooth image regions, highlighted by the darker areas in the error map of the BALLOONS test image.However, the performance of the deep learning based filters is contingent upon the structure of the images, occasionally resulting in visible artifacts, especially at edges.
The error maps, alongside the MAE values, affirm the strong denoising capability of the proposed filtering framework.It is important to highlight that the MINOR G method effectively filters the test images with a contamination level of p = 30 , showcasing the lowest MAE values and signifying its high capacity to preserve image details.
The performance of the MINOR method can be also assessed when filtering real noise contamination in cDNA image which determines gene expression levels 128 .As can be observed in Fig. 18, impulsive noise is removed, edges are well restored and the visible color artifacts, resulting from incorrect alignment, are eliminated.The beneficial properties of the new filter are also illustrated when denoising a part of the painting "Girl Vol.:(0123456789)   with a Pearl Earring" by J. Vermeer, (Fig. 19).The painting cracks are removed, no color speckles are created in the painting's homogeneous areas and the details are well preserved.

Conclusion
In this paper, a novel technique intended for the reduction of high intensity mixed Gaussian and impulsive noise in color images has been proposed.The elaborated approach is based on the novel dissimilarity measure between image patches, incorporated into the design of the Non-Local Means technique.The new filter discards from each patch the pixels with the highest dissimilarity to the central window of the processing block, which ensures the suppression of impulsive noise and enables to smooth out the Gaussian noise component.Thus, for each patch in the block, the most similar pixels to the central patch are determined and used for blockwise NLM smoothing.The proposed approach is well suited for highly contaminated images, whose corrupted pixels should be excluded from the averaging process.Additionally, we observed that for high noise contamination level, the classic approach used in NLM, which is based on averaging of a stack of images created from corresponding pixels from the local patches, does not fully exploit the potential of the proposed framework, especially in terms of visual quality and the ability to remove the impulsive noise.Better denoising efficiency is achieved when averaging globally all pixels in the block.In this way, the role of the low weights assigned to corrupted pixels is diminished and the final restoration result is composed of pixels which were not significantly affected by the mixed noise.The comparison with a variety of filters intended for the suppression of mixed noise in color images revealed the satisfactory properties of the proposed denoising framework, especially at high contamination levels.The efficiency of the new filter was confirmed on a large set of test color images and was also verified when denoising images corrupted by noise of unknown structure.The computational efficiency of the proposed filter is moderate, comparable to NLM, allowing for its implementation in real-time scenarios.
Future work will be focused on the refinement of the proposed dissimilarity between image patches by taking into account the measure of pixel corruption evaluated using digital paths exploring the local neighbourhood of pixels.Additional effort will be devoted to the elaboration of an adaptive technique, which will automatically

Figure 2 .
Figure 2.Processing block B i of radius r = 5 centered at x i with patches W i , W j and W k with size s = 1 , (a).The processed pixel x i (marked in dark gray) is included in the central patches W iv of the corresponding blocks shifted to x iv , (v = 1, . . ., 9) (b). https://doi.org/10.1038/s41598-023-48036-1

Figure 3 .
Figure 3.The estimate of the left pixel x i4 from the central patch W i is computed considering the similarity to patches of the processing block.

Figure 4 .
Figure 4. Illustration of the proposed dissimilarity measure in the 2D case.For each point a i ∈ A , the average of α smallest squared distances to points b i ∈ B , is computed.Then, the mean of the β smallest values is determined and it serves as a dissimilarity measure between sets A and B.

Figure 5 .
Figure5.Computation of the dissimilarity measure.The pixel intensities within W i nearest to x j4 are highlighted in bold, while pixels from W j exhibiting the highest similarity to W i are distinguished by a green color.

�o i − y i � 2 ,Figure 7 .
Figure 7.Comparison of execution times of the NLM and MINOR G filters with recommended parameters using images of increasing resolutions.

Figure 8 .
Figure 8. Color test images used for the experiments.

Figure 11 .
Figure 11.Distribution of parameters yielding the best possible PSNR values, evaluated on a set of 100 color images 116,118 , corrupted with MGIN of levels p = 10, 30, 50.

Figure 12 . 13 .
Figure 12.Dependence of α and β parameters providing the best possible PSNR values using the images depicted in Fig. 8.

Figure 14 .
Figure 14.Dependence of the best possible PSNR values on the α and σ when β = 5 (a-c) and on β and σ when α = 4 (d-f) using image PEPPERS and setting block size r = 6.

Figure 15 .
Figure 15.Efficiency of the evaluated filters when using the BALLOONS test image contaminated with MGIN of p = 30.

Figure 16 .
Figure 16.Efficiency of the evaluated filters when using the MONARCH test image contaminated with MGIN of p = 30.

Figure 17 .
Figure 17.Error maps of the most efficient filters when using the BALLOONS and MONARCH test images contaminated with MGIN of p = 30 .The MAE values are enclosed in brackets.

18 .
Filtering efficiency of the proposed MINOR G filter when denoising a noisy cDNA image.The artifacts caused by misalignment of the spots are successfully removed.

Figure 19 .
Figure 19.Filtering efficiency of the proposed MINOR G filter when performing a virtual restoration of the painting "Girl with a Pearl Earring" by J.

Table 1 .
109ommended parameters of the patchwise NLM109and the proposed MINOR G denoising technique.

Table 2 .
Comparison of quality measures of noisy images restored by the MINOR filter and competitive techniques.The top three results are distinguished in bold and italics, with the best result presented in bold.