# Impulsive Noise Removal with an Adaptive Weighted Arithmetic Mean Operator for Any Noise Density
## 3 Weighted Arithmetic Mean Based Fuzzy Filter Algorithm
### Noise Detection Phase Based on Fuzzy Open-Close Operators
The formula of the aggregation function is as follows:

\[\text{WAM}(p_{1},\ldots,p_{m_{0}})=\sum_{k=1}^{m_{0}}w_{k}p_{k}, \tag{2}\]

where the weights \(w_{k}\) for all \(1\leq k\leq m_{0}\) are given by

\[w_{k}=\frac{\alpha_{k}}{\sum_{t=1}^{m_{0}}\alpha_{t}},\text{ where }\alpha_{r}=\frac{1}{\beta^{d((i_{r},j_{r}),(i_{0},j_{0}))}}\text{ for all }1\leq r\leq m_{0}, \tag{3}\]

where \(\beta>1\) and the \(d\) is a distance on \(\mathbb{Z}^{2}\). Please note that these weights are based on an exponential decay with respect to the distance between the available non-noisy pixel and the pixel that is currently being processed. This ensures that if this distance increases, the weight of the noncorrupted pixel in the final output is smaller. It is evident that the performance of the filter relies heavily on (i) the least quantity of non-noisy pixels considered in the aggregation function, which is denoted by \(n\), (ii) on the exponential base of the weights, \(\beta\) and (iii) on the considered distance, \(d\). In Section 4.3, an in-depth analysis of the optimal values of these three parameters according to the noise level is included. Let us explain how the search of those pixels designated as noncorrupted (at least \(n\)) is implemented to restore a concrete corrupted pixel \(p_{0}\). Let \(D=1\) and take into account the set of all the noncorrupted pixels whose distance to \(p_{0}\) is \(\leq D\). If a minimum of \(n\) non-noisy pixels are found, no more iterations are necessary and these pixels will be aggregated by using Equation (2). Otherwise, \(D\) is incremented by \(1\) and the search resumes. This step ends when enough non-noisy pixels are found. It is clear that the search step does depend on the considered distance. In Figure 2, the evolution of the search window for each of the distances considered in Section 4.3 is displayed. Figure 2: Evolution of the search window (in black) of noncorrupted pixels for some values of \(D\) in a \(7\times 7\) image and three different distances. Summarising the filtering stage, let \(A\) be the corrupted image, \(b\) the image computed in step 3) of Algorithm 2, \(n\) the minimum number of non-noisy pixels to perform the aggregation, \(\beta\) the base of the exponential function considered in the weights and \(d\) the selected distance. For each corrupted pixel \(p_{0}=A(i_{0},j_{0})\) detected by the noise detection function, the following steps are carried out:

```
1. Let \(C_{D}=\{p_{k}=A(i_{k},j_{k})\mid d((i_{k},j_{k}),(i_{0},j_{0}))\leq D\text{ and }b(i_{k},j_{k})=0\}\) be the set of pixels that has been classified as non-noisy in the first phase at a distance \(\leq D\) from \(p_{0}\). 2. Set \(D=1\). 3. Compute \(|C_{D}|\) where \(|\cdot|\) denotes the cardinal of a set. If \(|C_{D}|<n\), then \(D=D+1\) and repeat this step. Otherwise, go to the next step. 4. The output gray-level value of the processed pixel \(\widehat{p_{0}}\) is given by \[\widehat{p_{0}}=\text{WAM}(p_{1},\dots,p_{m_{0}}),\] where \(p_{i}\in C_{D}\) for all \(1\leq i\leq m_{0}=|C_{D}|\) through Equation (2) with base \(\beta\) and distance \(d\). ```

**Algorithm 2**(Filtering Phase)

From now on we will denote this filter as the adaptive weighted arithmetic mean, AWAM for short. ## 4 Comparison Experiments and Analysis

In this section, first, we will describe the image database that we used in the visual and numerical experiments. To find the best parameter configuration of the proposed filter, we will explain how we divided the image database into the training and test sets. Next, we will present the performance measures to compare the filters considered in this work. The last part of this section will be devoted to the description of the considered filters and the numerical and visual results of the experiments. ### Image Database

To analyse the performance of the proposed filter, a set of experiments were carried out over a set of 44 images. We selected the 36 natural images that belong to the miscellaneous set of the USC-SIPI image database developed by the University of Southern Carolina.