Self-tuning fast adaptive algorithm for impulsive noise suppression in color images

In this paper, a self-tuning version of the newly introduced Fast Adaptive Switching Trimmed Arithmetic Mean Filter, which is a very efficient technique for impulsive noise suppression, is elaborated. Most of the methods presented in the rich literature have numerous parameters, whose proper settings are crucial for efficient noise suppression. Although researchers often provide recommended values for their algorithms’ parameters, the actual choice remains in the hands of the user. Our goal is to free the operator from parameter selection dilemma and to propose an algorithm which includes required expert knowledge within itself. The only obligatory inputs of the proposed algorithm (from the user perspective) are the image itself and the size of the operating window.


Introduction
Rapid development of miniaturized high-resolution, lowcost image sensors, dedicated to operate in various lighting conditions, makes image enhancement and noise suppression to be very important operations of digital image processing.
There are various types of noise which affect acquisition and processing of digital color images. The disturbances may be introduced by [1-6]: • electric signal instabilities, • physical imperfections in sensors, • corrupted memory locations, • transmission errors, • aging of the storage material, • natural or artificial electromagnetic interferences. Therefore, noise suppression is one of the most frequently performed low-level image processing tasks [1,2,5,6]. There are plentiful different techniques tailored for suppression of distinct type of noise, but most of them are vulnerable to occurrence of a impulsive noise, which introduces significant deviations of color image channel values [7][8][9]. Therefore, the suppression of the impulsive noise is a critical step of image preprocessing.
Impulsive noise removal techniques are contextual processing schemes which estimate the channels of the processed pixel using information obtained from its neighborhood, represented by a sliding operational window. Many of them are based on a vector-ordering scheme [10][11][12][13][14], and use cumulative distances between samples in a window as dissimilarity estimates. Those accumulated distances are then sorted and constitute the basis for further processing in various filtering algorithms.
One of the most basic filtering techniques, utilizing this ordering scheme, is the vector median filter (VMF) [10,15]. The output of VMF is the pixel from operational window for which the sum of distances to other samples from the window is minimized. Although this filter does not introduce any new colors to the processed image, there is no guarantee that the output pixel is itself noise-free, and thus, numerous solutions were developed to solve this problem and improve filtering performance [16][17][18][19][20][21].

3
The main reason, that the efficiency of vector-ordering schemes is limited, lies in processing of every image pixel, regardless whether it is corrupted or not. Unnecessary processing of noise-free pixels results in inevitable degradation of the image quality. To address this issue, a significant improvement has been made by introduction of more sophisticated switching filters [22][23][24][25][26][27][28][29][30][31], which focus on the restoration of corrupted pixels only.
The switching techniques use various approaches to determine if the processed pixel is corrupted or not. Then, only those classified as noisy are further processed by the output estimation algorithm. This way, not only the quality of output of restored image is preserved, but also a significant reduction of the computational cost is often achieved.
The Fast Adaptive Switching Trimmed Arithmetic Mean Filter (FASTAMF), concerned in this paper, has been proposed recently [54] and is a very efficient technique from both noise suppression efficiency and computational cost point of view. The main practical drawback of the algorithm (which is common among alternatives) is the necessity of manual parameter adjustment to image noise contamination severity, to achieve its optimal performance. Therefore, the main goal of the research presented here is the introduction of a self-tuning mechanism, so that manual experimental choice of the main filter parameter (threshold) will no longer be required.

Notation
For the purpose of better readability of subsequent sections describing the concerned algorithm design, the following notations are introduced: • M-original map of noise acquired using artificial image contamination. • m u,v -real state of pixel corruption located at (u, v) (0noisy; 1-noise-free), • M -final estimated map of noise acquired during noise detection phase. • m u,v -classification of pixel contamination located at u, v (0-noisy; 1-noise-free). • W-local operating window centered at x u,v , containing pixels from direct 8-neighborhood, • x i -ith pixel of the local operating window W (the pixel • (r) -rth smallest distance among all i computed for the same W, • c u,v -sum of smallest distances, representing raw impulsiveness of particular x u,v , • W c -window containing values of raw impulsiveness computed for every pixel from local neighborhood of currently processed pixel x u,v , • c min -smallest accumulated distance in W c representing simple estimate of image structure, • s u,v -corrected impulsiveness measure of pixel at position u, v, • k-iteration number in self-tuning (ST) procedure, • l-iteration number in multiple run test, • t-threshold value (filter parameter), • t k -threshold value adjusted in the kth iteration of the self-tuning, • AMF(W)-output of the Arithmetic Mean Filter, • -true noise density used in artificial image contamination. • ̂-estimated noise density obtained through noise detection phase, • ̂k-estimated noise density obtained in the kth iteration of self-tuning procedure, • R , G , B -probability of contamination of channels in RGB color space, • A -probability of contamination of all pixel channels at once, • M k -estimated map of noise obtained during kth iteration of self-tuning, • , -height and width of the image (in pixels), • -number of pixels in X ( = × ), • n k -number of pixels designated as noisy during kth iteration of self-tuning, • p-probability of error in statistical reasoning (result of statistical test which allows to hold or reject a null hypothesis). • k F -final number of iterations of self-tuning procedure, required to satisfy the convergence condition.
In above, three-dimensional arrays (e.g., images, operating windows) are denoted using emboldened capital letters, twodimensional arrays (e.g., map of noise) are indicated as normal capital letters, vectors (like single pixel) are presented as emboldened lowercase characters, and, finally, scalars are represented in normal lowercase manner.

Impulsive noise models
In this paper, four different noise models are considered [55,56]. In all of those models, the main parameter is the noise density ( ) expressed by the percentage of corrupted pixels in the processed image: • Channel Together Random Impulse (CTRI)-if a pixel is noisy, all of its RGB channels are corrupted. • Channel Independent Random Impulse (CIRI)-if a pixel is contaminated, the alteration of every channel is independent. • Channel Correlated Random Impulse (CIRI)-if a pixel is contaminated, then the corruption of channels is correlated with fixed correlation coefficient. • Custom Probability Random Impulse (CPRI)-if a pixel is contaminated, there is a fixed set of probabilities that single RGB channels are corrupted ( R , G , B ) or that all channels are corrupted together ). The model does not take into account the corruption of two channels at once.
In all above models, contaminated pixel channel is represented by a random value taken from full encoding range: ⟨0, 255⟩ (for 8-bit RGB image coding).

Performance measures
The noise detection efficiency alone can be evaluated using binary classification. The result of noise detection, represented by estimated noise map M , is compared to the original noise map M, established during artificial image corruption, which is treated as true information of noise occurrence. After comparison, each pixel can be assigned to one of the following classes: • True positive (TP)-pixel was correctly recognized as being contaminated. • False positive (FP)-pixel was falsely classified as noisy-also known as Type-I error. • True negative (TN)-pixel was correctly recognized as not corrupted. • False negative (FN)-pixel was incorrectly classified as not noisy-also known as Type-II error.
After an assignment of above states to every pixel in the image, the detection performance can be measured using accuracy: where |TP|, |TN|, |FP| and |FN| are cardinalities of pixels assigned to particular categories. The overall noise suppression efficiency can be evaluated using many different performance measures. In this paper, we consider the following: where L, a, b are the coordinates of the original and L ,â,b of restored image pixels, both in CIE Lab color space [1].
In addition, the Feature-SIMilarity index for color images (FSIMc), [57] was used to provide additional information about noise suppression performance. In contrast to Peak Signal-to-Noise Ratio (PSNR), Mean Absolute Error (MAE), and Normalized Color Difference (NCD), which operate on individual pixels, thus compare images in context-free manner, the FSIMc index, is based on the properties of the human visual system.

Original FASTAMF algorithm
The FASTAMF [54] algorithm is composed of two main processing phases ( Fig. 1): 1. noise detection-the noise map ( M ) is estimated upon input image ( X ), using reduced ordering scheme and PSNR =10 log 10 255 2 MSE ,

3
two parameters provided by the user: operating window size (w) and threshold (t). 2. pixel replacement-the output image ( X ) is obtained using input image ( ), and noise map ( M ) provided by noise detection phase. Only pixels classified as noisy are processed by AMF with operating window size w.
The filter operates on every pixel of input image X located at coordinates (u, v), denoted as x u,v , using operational window W containing n = w 2 samples. Pixels in W are denoted x 1 … , x n , and x 1 = x u,v is the center pixel of W (Fig. 2).

Noise detection
The noise detection phase is composed of the following steps: I. Evaluation of pixels impulsiveness begins with computation of dissimilarity measure d(x 1 , x j ) between the central pixel and every other pixel contained in W, denoted as i . Originally, the Euclidean distance was used, but many other dissimilarity measures can be used instead [11]. For example, in [58], the authors show that the use of Chebyshev distance ( L ∞ ) improves detection performance, because this way algorithm is then more sensitive to outliers occurring on individual channels. Next, distances i (excluding The c u,v can be interpreted as raw impulsiveness of the pixel (Fig. 3). II. Adaptation to local image variation is performed.
For every c u,v , a window W c , containing n values c i , is taken, so that c 1 = c u,v is in the center of that window. The final corrected measure of corrected pixel impulsiveness ( Fig. 4) assigned to pixel x u,v is obtained: where c min = min{c ∈ W c } . This correction normalizes impulsiveness based on the local image variation. In homogeneous image regions c min is close to 0 x 5 x 6 x 7 x 8 x 9 and it rises together with variation in local neighborhood. As a result, the pixels of high raw impulsiveness in harsh regions of the image are less likely to be classified as noisy pixels of the same raw impulsiveness in smooth areas.
III. Noise map acquisition finalizes the noise detection phase, during which the estimated noise map M is obtained. It is achieved by the comparison of s u,v to the threshold t, provided by the user, for every pixel in the image X as follows: The labeling of noisy pixels as 0 in M is needed for the subsequent pixel replacement phase.

Pixel replacement
In the pixel replacement phase, the output image is obtained according to the following rule: where AMF(W ) is the arithmetic mean computed only on members of W , which were designated as noise-free. In rare occasions (occurring for very high noise densities), when there is no noise-free pixels in W , the output is determined using the VMF scheme.

Self-tuning
As it has been shown in Fig. 1, there are three inputs for the algorithm: processed image ( X ), threshold (t), and operational window size (w). As long as w is intuitive parameter to adjust, the proper choice of t may be a difficult one. It was shown in [54,58] that optimal choice of t is dependent on impulsive noise density ( ), which is mostly unknown in real-case scenarios, so the operator is forced to experimental search of adequate value of t.
To free the user from manual adjusting of this parameter, a self-tuning modification is introduced. The main concept of this improvement is to use the estimated noise map M (obtained during noise detection phase) to compute the estimated noise density ̂ . Combining ̂ with proper tuning characteristics like provided in [58] enables to adjust the t value, which can be used to obtain more accurate noise map.

Algorithm
Based on the aforementioned idea, the self-tuning modification is introduced (Fig. 5). Before execution of the algorithm, the input t is set to initial value t 1 = 60 (recommended value for t in FASTAMF using Chebyshev distance, obtained experimentally). Then, the noise detection is performed until corrected impulsiveness measure is obtained for every pixel in the input image X. Next, the recursive procedure of automatic t adjustment is performed by the following steps: (a) The estimated map of noise for the current iteration M k is obtained by (9) using t k . (b) The estimated noise density for the current iteration ̂k is evaluated: ̂k = n k ∕ , where n k is the number of pixels designated as corrupted (in kth iteration) and is the number of pixels in image X. (c) t k+1 value is interpolated (simple linear interpolation between two closest values) using tuning tables (see Table 4), which were obtained using procedure presented in Sect. 3.2.
Steps (a)-(c) are repeated in a loop until desired convergence |t k+1 − t k | < is achieved, where regulates the convergence. In all experiments presented in this paper, = 1 was used.
Final estimated map of noise, denoted as M , is then taken as an input to the pixel replacement phase. It is important that only the final step of the entire noise detection phase (9) has to be recursively repeated, so the increase in computational cost is not significant.
Although it might be tempting to design a similar solution for the adaptive tuning of operation window size w, it is pointless to do so due to the following reasons: • It is very intuitive to choose w value, and using windows larger than 3 × 3 is reasonable for high noise intensities only ( > 50%). • Window size w has a critical impact on computational cost of the algorithm, so its automatic on-the-fly tuning certainly makes its execution time extremely unpredictable. • Alteration of the w during algorithm's execution requires repetition of the entire noise detection phase, which is very costly form computational point of view. Therefore, such tuning algorithm would be inapplicable for realtime image processing tasks. • Preliminary tests (omitted in the paper) revealed that w has stronger impact on noise detection phase performance than on pixel replacement phase. Therefore, partial solution, assuming the use of altered on-the-fly w for pixel replacement phase only, resulted in lack of restored image quality improvement.

Tuning tables
The core of the self-adjusting threshold t modification is the tuning Table 4 which provides the t values for interpolation step (c). Originally, this table was proposed for CTRI and CIRI noise models in [58]; however, in this paper, more thorough experiments were performed, to obtain more general insight into the problem. The set of 100 color images has been taken as the training set (Fig. 6) [59]. Each of those images was artificially contaminated with CIRI, CCRI (correlation coefficient set to 0.5) and CTRI model for noise densities  Finally, for each contaminated image, the optimization has been performed to find optimal value of t for which ACC, PSNR, and FSIMc are maximal and MAE and NCD is minimal.
The mean values (and standard deviations) of optimal t, computed upon entire set of training images for a chosen performance measure, noise model, and noise density are presented in Tables 1, 2, and 3. The final proposition of general tuning values obtained as an average of results from all experiments is shown in Table 4.

Noise suppression performance
Our aim was to provide the most objective noise suppression performance test; therefore, a new set of ten images was taken as validation set (Fig. 7) [60]. In addition, all of those validation images were contaminated with CPRI noise ( p R = p G = p B = p A = 0.25 ), which has not been used for obtaining the tuning Table 4. This way, we provided an independent test input, further minimizing the possibility that the tuning values are optimized for particular image set or noise model.

FASTAMF compared with state-of-the-art algorithms
While original FASTAMF algorithm [54] was operating on Euclidean distance, the new version uses its Chebyshev counterpart. Therefore, a new comparison to state-of-theart filters is required. This time, we decided to restrict the state-of-the-art algorithm base to four filters, which were found to be the most competitive using the recommended parameter settings: 1 • FASTAMF with recommended t = 60. For all tested algorithms, the operating window size was set to w = 3 and the comparison was performed for noise densities ∈ {10, 20, … , 50%} . For each corrupted image from validation set and for each tested algorithm, the noise  • H2: There is no evidence that FASTAMF performs significantly better than the compared algorithm. • H3: There is evidence that FASTAMF performs significantly better than compared algorithm.
The results of above tests are summarized in Table 5 (Friedman's tests) and in Table 6 (Post hoc tests). All emboldened values in the tables do not support the superiority of the FASTAMF (as those are in minority). In case of PSNR and FSIMc measures, the better value is the higher one, so the higher mean rank values support the superiority of particular algorithm. The opposite situation is for MAE and NCD measures which are better if smaller.
The following conclusions can be drawn: • The results obtained from all algorithms (represented by quality measures) were always heterogeneous (H0 was discarded in favor of H1 in every case). In addition, p in each Friedman's test was very low, so the differences in results are unquestionably significant. • For every measure and noise density, the best mean ranks were observed for FASTAMF algorithm, which means that it was the best or almost the best for every tested image. • Only very few of Post hoc tests resulted in favor of H2 hypothesis. For those rare cases, we can state that FAS-TAMF is not significantly better than the compared algorithm. For each other case, however, it is the best performing algorithm among tested. • For low-noise densities, the ACWVMF tends to be a competitive choice for FASTAMF, while, for higher noise contamination ratios, the FAPGF provides the most similar results.

Self-tuning FASTAMF against original FASTAMF
The main goal of self-tuning feature is to free the user from experimental threshold selection, which is optimal for a given noise density. Therefore, self-tuning FASTAMF (further denoted as STF) is compared to the original FAS-TAMF (further denoted as OF from Original Filter) with recommended t = 60 . This time, only two algorithms were compared, so Wilcoxon's test [62] was used (not every sample has normal distribution, so t test cannot be preformed).
The following hypotheses were formulated: • H0: There is not enough evidence that STF provides significantly better results. • H1: There is enough evidence that STF provides significantly better results.
The results are presented in

3
The results obtained are very satisfactory. It is obvious that ST modification is not significantly better for lower values due to the recommended fixed t being suitable for such scenarios. In addition, while becomes higher, the better performance of STF becomes more noticeable, as this algorithm automatically adjusts its optimal threshold value.

Multi-run and visual comparison
One of the common approaches to achieve good noise suppression performance is to repeat the processing of the noisy picture several times, using output image as an input for next algorithm's execution. This way noisy pixels omitted during first filtering may be detected and restored during subsequent runs. However, this approach may lead to stronger degradation of image details, especially if the algorithm has adaptive features.
The noise suppression scheme (further referenced as multi-run or MR) was performed for three iterations ( l = 1, 2, 3 ) upon all the validating images for noise densities ∈ {10, 30, 50} , and the four representative images were selected for detailed comparison (validation images 1, 7, 8, and 9).
To provide fair comparison, two images for which OF algorithm achieved a better performance in the MR test (validation images 7 and 9) were opposed to two images for which ST provided better results (validation images 1 and 8). The OF scheme was applied for three iterations with the same recommended t = 60 , while STF algorithm calculated threshold value automatically in each iteration.
The efficiency of both algorithms in terms of PSNR and FSIMc measures is presented in Table 8. In addition, the visual comparison of performance for both filtering schemes for l = 1 , l = 3 and = 30% is depicted in Figs. 10, 11, 12, and 13.
As can be seen, the STF algorithm performs better for "easier" tasks (validation images 1 and 8)-which are meager in detail and have large homogeneous regions (Figs. 10 and 12). The threshold value t is well adjusted in the first execution (Fig. 8), and then, it is set automatically to higher value in subsequent runs. This is caused by low estimated noise density after first noise suppression and is beneficial for the purpose of detail preservation. The STF algorithm does not try to repair less explicit outliers, which might be the image details.
For harder tasks, however (validation images 7 and 9)images rich in small details (Figs. 11 and 13)-a large value of ST might be too high to enable the restoration of omitted noisy pixels (Fig. 9). The OF algorithm with fixed t shows higher efficiency, while it tends to restore pixels with the same impulsiveness.
We can observe that although the self-tuning feature of the algorithm is very convenient and may achieve a better statistical performance, especially if the noise density is unknown or non-stationary, it may achieve slightly inferior efficiency than fixed t value version for more complicated images.
A more detailed analysis of zoomed regions on images 1 and 8 (Figs. 10,11,12,13) shows that: • the OF removes less noisy pixels for l = 1 than its STF counterpart (Fig. 10c, d), due to higher value of t. If the reason behind those leftovers is high variance of the local area, those are mostly removed in subsequent iterations (Fig. 10e). If a too high t value caused this omission, those will not be restored, no matter how many iterations will be performed. In addition, fixed t value makes OF completely insensitive to less explicit noisy pixels, which is reflected in numerical (PSNR) and structural (FSIMc) measures; • the STF scheme removes more noisy pixels in the first execution (Fig. 10d), strongly decreasing the local variance of the image. Consequently, it is easier to remove  omitted noisy pixels in subsequent iterations (Fig. 10f), and there is also lower count of less explicit noisy pixels due to lower t in the first run; • the STF scheme tends to remove more details (Fig. 11d, f) from the image (it is more blurry), than OF (Fig. 11c, e). As long as it is hard to be noticed visually without zoom, it clearly affects numerical (PSNR) and also structural (FSIMc) measures; • undetected by OF noisy pixels during the first execution (Fig. 12c), may cause low-level distortions around them, which will not be repaired in subsequent iterations (Fig. 12e). Such phenomenon is far less noticeable if STF scheme is used (Fig. 12d, f). • STF scheme tends to remove more details in the most difficult cases (Fig. 13d, f), which is reflected mostly by the PSNR measure.
It has to be pointed out that images 1 and 8 contain large homogeneous regions which makes the adjustment of t easier. In contrast, the high local variance of regions occurring in images 7 and 9 makes t tuning harder. As long as very large number of distinct images was used as training set for obtaining the tuning Table 4, the local variance of the image has not been taken into account, nor it is measured in any way during t adjustment. Such approach was considered and tested in the early stages of STF development, but it was very computationally expensive, so not applicable for real-time implementations.
The visual comparison shows that STF algorithm seems to always achieve a better noise suppression efficiency (less explicit leftovers can be noticed). Therefore, lower PSNR values might be caused by very subtle differences, which can be detected on the numerical level only. Fig. 9 Algorithm's performance in subsequent iterations for validation images 7 and 9 (for which OF performs better) 1 3

Computational complexity
A detailed analysis of computational complexity of algorithm is presented in [54]; therefore, in this paper, it has been performed for ST modification only. Self-tuning begins after the computation of corrected impulsiveness and in each iteration k requires: 1. Estimation of map of noise M k which needs × comparisons (COMPS). This step has linear complexity.
where A and B are the nearest indicates of values in Table 4 for which A ≤̂k ≤ B . It demands 5 subtractions (SUBS), 2 divisions (DIVS), 2 multiplications (MULTS), and 1 addition (ADDS) and up to 18 COMPS (required for determination for A and B). This step is not image size-dependent, so it can be treated as step with constant computational complexity. The remaining issue is the number of iterations required to achieve desired convergence. For every image in training image set, noise models: CTRI, CIRI, and CCRI, and noise densities ∈ {0.1, 1, 5, 10, 15, … , 80%} STF algorithm has been executed and the number of iterations (denoted as k F ) needed to satisfy the convergence condition has been obtained. The results are presented in Table 9. It can bee seen that the k F is very stable and has almost deterministic value. The computational cost of single iteration of ST modification is not very heavy and is linearly dependent on image size. The number of iteration required to archive final t values is fairly low and predictable, so this modification is a suitable addition to FASTAMF algorithm in terms of realtime image processing requirements.

Experimental comparison
The execution time and noise suppression efficiency of FASTAMF with ST modification has been compared to the original FASTAMF (with recommended t = 60 ). In tests, all ten images' validation set (Fig. 7) contaminated with CPRI model and noise densities ∈ {10, 20, 30%} is used. The noise suppression efficiency has been evaluated by PSNR, MAE, NCD, and FSIMc measures. Since the tuning tables were obtained as the trade-off between those measures, in Fig. 14, the most favorable (NCD) and most adverse (PSNR) outcomes of using ST modification were presented. On vertical axis, the difference in particular measure is presented, while, on horizontal one, the change of execution time (in percentages) is exhibited. The point (100,0) refers to all results obtained using original FASTAMF algorithm, and marked points represent results obtained for ST version using ten test images.
Interestingly, in individual cases for = 10% , the ST version might be even faster than original algorithm, because the threshold value is calculated to be higher then t = 60 . As a consequence, fewer pixels are recognized as noisy, and noise suppression (AMF) has less work to do.
Also the major conclusion is that results for ST modification become better, along with increasing noise density.

Summary
The achieved denoising results are very satisfactory, since the reduction of the number of FASTAMF parameters and a better overall performance have been the main goal of this research. The new self-tuning FASTAMF, achieves slightly better or at least not worse overall performance than the original algorithm, yet it has no parameters which require experimental adjustment.
Also the computational cost of the self-tuning is not significantly higher, since it works after the most computationally expensive part of the algorithm (estimation of the pixel impulsiveness). The major virtue of the self-tuning FASTAMF is its adaptability to noise density. As it can be useful for filtering of images contaminated by impulsive noise of unknown density, it might be even more advantageous for processing of video sequences distorted by noise with time-dependent parameters. The initial value of t (for self-tuning mechanism) can be carried out from frame to frame, in such  implementations, decreasing the number of potential iterations, required to achieve required convergence. The application of proposed filtering scheme to the video enhancement will be the subject of future work.  3  3  3  3  4  4  4  4  Med.  3  3  3  3  4  4  5  4  Max.  3  3  3  4  5  6  6  5