# 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
It is straightforward to check whether, if the image is corrupted by a higher density noise, the corrupted pixel has fewer noncorrupted pixels in its neighborhood. Thus, the filter needs to consider an increasing sequence in size of neighborhoods centred at the corrupted pixel until a certain reasonable quantity of noncorrupted pixels are available in order to get a representative value when the aggregation is computed. This can be observed in Figure 1. Salt-and-pepper noise at a 90% density has been applied to the original image given in Figure 1a. The corrupted image is available at Figure 1b. A detail near the dreadlocks has been selected in both images (Figure 1c,d). The result provided by the first stage, explained in Section 3.1, can be seen in Figure 1e where all the pixels were correctly identified as corrupted or noncorrupted accordingly. At this point, in order to reconstruct the central pixel of the detail, which is a corrupted pixel, we will consider, for instance, a sequence of squared neighborhoods centred at this pixel of sizes 3, 5 and 7. As it can be observed in Figure 1e, there are 0 noncorrupted pixels in the \(3\times 3\)-neighborhood. There are only 3 noncorrupted pixels in the \(5\times 5\)-neighborhood, but this number increases to 7 when the \(7\times 7\)-neighborhood is considered. It is clear that the size of the neighborhood to obtain a reasonable number of noncorrupted pixels may vary for each pixel of the image. The unavoidable need to use noncorrupted pixels which are quite distant from the central corrupted pixel has an important drawback. The probability that the gray-level value of an arbitrary noncorrupted pixel is close to the original gray-level value of a noisy pixel decreases when the distance between them increases. Therefore, the closer a noncorrupted value is to the corrupted pixel, the more reliable is its value and its influence must be higher in the output. This is certainly the case in the original detail of Figure 1c. However, this idea does not hold in certain cases. For instance, near an edge, depending on its direction, closer pixels can have distant gray-level values when compared to the central pixel as long as they are located at the other side of the edge. See for instance Figure 1g which corresponds to a detail located near the arm of the man where an edge divides a black region and a lighter region. After applying the first phase of the algorithm, only four pixels are classified as noncorrupted and can be used for restoring the corrupted center pixel (see Figure 1i). Pixel with value 7 is closer than pixel with value 163 although this latter pixel has a more similar value to the centre pixel. Nevertheless, taking into account that (i) edges constitute a small part of the image and (ii) the impossibility to detect edges in images with a high percentage of salt-and-pepper noise, the proposed algorithm will follow that general rule. Figure 1: Two graphical examples of the result of the function described in the noise detection stage introduced in Section 3.1 and the available noncorrupted pixels. The implementation of the previous idea can be easily done by using an aggregation function that applies weights to the noncorrupted input pixels based on how far the input pixel is from the corrupted pixel which is currently being processed. In this paper, a weighted arithmetic mean function (WAM), introduced in Definition 2, is considered. Let us describe the method to compute the weights of the WAM operator. Let \(p_{0}=A(i_{0},j_{0})\) be the pixel that is going to be processed and \(\{p_{1},\ldots,p_{m_{0}}\}=\{A(i_{1},j_{1}),\ldots,A(i_{m_{0}},j_{m_{0}})\}\) be the \(m_{0}\) noncorrupted pixels which will be aggregated to reconstruct \(p_{0}\). Please note that \(m_{0}\) depends on the pixel \(p_{0}\), and the only requirement that we impose is that it must exceed \(n\), which is the least number of non-noisy pixels that are going to be considered to restore \(p_{0}\).