# 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 noise detection phase is usually implemented through a noise detection function which classifies each pixel of the image as corrupted or noncorrupted by the considered noise. From the straightforward salt-and-pepper noise detection function that classifies as corrupted those pixels which are black or white to the most advanced ones based on morphological operations, several different approaches were analysed in the literature to detect salt-and-pepper noise. Here, we will consider the same noise detection function used in [14]. This noise detection function has proved its potential for corrupted images by high-density salt-and-pepper noise (\(\geq\)90%) and most of the corrupted pixels are detected. In Section 4.3.1 a comparison of this algorithm with other functions designed for noise detection proposed in the literature is performed to justify this choice. The proposed noise detection function has its origins in the noise detection function used in [26] but was improved recently by considering fuzzy mathematical morphology operators instead of the standard gray-scale morphological operators. The key idea is to use adequate combinations of the fuzzy opening and closing, leading to the so-called alternate filters. We recall here, for the sake of completeness, the steps of the Algorithm 1 where \((i,j)\) denotes a pixel of the corrupted image \(A\):```
1. Detect the minimum (\(S_{\text{min}}\)) and the maximum (\(S_{\text{max}}\)) values of a squared window of size \(N\) centred at \((i,j)\). 2. Calculate value \(d\) as \[d(i,j)=\left|\frac{C_{T,I_{T}}(O_{T,I_{T}}(A,B),B)(i,j)}{2}+\frac{O_{T,I_{T}}(C_{ T,I_{T}}(A,B),B)(i,j)}{2}-A(i,j)\right|\] where \(T\) is a t-norm and \(I_{T}\) is its \(R\) implication. 3. Calculate value \(b\) as \[b(i,j)=\left\{ \begin{array}{ll}255,&\text{if }(A(i,j)=S_{\text{max}}\text{ or }A(i,j)=S_{\text{min}})\text{ and }d(i,j)\geq t,\\ 0,&\text{otherwise},\end{array} \right.\] where \(t\) is a threshold which must be predefined. 4. \(A(i,j)\) will be considered to be a noisy pixel when \(b(i,j)=255\). ```

**Algorithm 1**Detection Phase)

### Filtering Phase Based on Aggregation Functions

Once the potentially corrupted pixels have been identified in the previous phase, the second phase is devoted to reconstructing these pixels only from the information provided by the remaining pixels. Please note that it would be pointless to use the gray-level values of those pixels identified as noisy by the previous noise detection function. However, this approach was the one used in the classical median or mean-based filters which aggregate the gray-level values of those pixels that belong to a neighborhood centred at a given pixel to reconstruct it. In fact, although state-of-the-art impulsive noise filters no longer apply this strategy preferring the two-phase approach considered also in this paper, incomprehensibly the mean and median-based filters are still in use in many block-chain computer vision algorithms. Focusing on the noise filter we present in this paper, the main idea is to aggregate the gray-level values of the pixels in the neighborhood in order to reconstruct a given pixel of the image. This idea is also the leitmotiv of the median or mean-based filters but, in this case, several restrictions and refinements are implemented to drastically boost the behaviour of the algorithm. First, we keep in the output image the gray-level value of all the pixels identified as noncorrupted in the noise detection stage. Thus, only those pixels classified as corrupted in the first phase are filtered. The reconstruction is based on an aggregation of the gray-level values of the neighboring non-noisy pixels. Although this idea is not novel, the novel key points of the proposed filter are the choice of the pixels to aggregate and the influence of each of these pixels in the aggregation. Let us explain in detail these two special features.