# An Advanced AFWMF Model for Identifying High Random-Valued Impulse Noise for Image Processing
## 3 The Proposed Adaptive Fuzzy Weighted Mean Filter Model
### Noise Cancellation by Adaptive Fuzzy Directional Weighted Mean
\right., \tag{14}\]  
where \(a_{in}=RefM_{i,j}-C2\times\sigma_{i,j},\ b_{in}=RefM_{i,j}-C1\times\sigma_{i,j},\ c_{in}=RefM_{i,j}+C1\times\sigma_{i,j},\ d_{in}=RefM_{i,j}+C2\times\sigma_{i,j},\ C1\leq C2.\ C1\) and \(C2\) are parameters that are predefined according to our extensive experiments. \(RefM_{i,j}\) is a reference value that can retain the details of the picture. \(\sigma_{i,j}\) represents the grade of dispersion of the filtering window. Pixels of the window farther from \(RefM_{i,j}\) show that the importance of the pixel is lower; conversely, closer pixels indicate a higher importance. Then, there are two membership functions corresponding to two output fuzzy sets: low and high sets; these are displayed in Figure 5.  
In Figure 5, the horizontal axis is the importance value, and it ranges from 0 to 1. On the vertical axis, we have the membership function of a fuzzy set denoted by \(x\), and this axis has values from 0 to 1. These two membership functions are output fuzzy sets. They are defined as Equations (15) and (16) below, respectively. \[low(x)=\left\{ \begin{array}{cc}\frac{O_{b}-x}{O_{b}},&x\leq O_{b}\\ 0,&x\geq O_{b}\end{array} \right., \tag{15}\]  
Figure 4: Four input attributions of three membership functions. Figure 5: Two output attribution functions. \[high(x)=\left\{ \begin{array}{cc}0,&x\leq O_{a}\\ \\ \frac{x-O_{a}}{1-O_{a}},&x\geq O_{a}\end{array} \right.. \tag{16}\]  
In this study, this characteristic is combined with fuzzy inference to decide the weight corresponding to the pixel. The output (the weight corresponding to the pixel) of the fuzzy inference of the proposed AFWMF model is based on three rules of filter stage as follows:  
**Rule 1. IF**\(x_{ij}\) is at nosie1, **THEN** its importance is low. **Rule 2. IF**\(x_{ij}\) is at noise2, **THEN** its importance is low. **Rule 3. IF**\(x_{ij}\) is at no-noise, **THEN** its importance is high. Additionally, we can use the above rules to obtain weights. Subsequently, the restoration pixel value \(u^{*}\) is calculated and formatted as Equation (17). \[u^{*}=\frac{\sum_{p=1}^{(2W+1)^{2}}wt_{p}x_{p}}{\sum_{p=1}^{(2W+1)^{2}}wt_{p}}, \tag{17}\]  
where \(wt_{p}\) is the weight corresponding to the pixel of filtering window, \(wt_{p}=0\)_to_\(1\), \(wt_{p}\in WT_{i,j}\), \(WT_{i,j}=\{wt_{s}|i-W\leq s\leq i+W\), \(j-W\leq t\leq j+W\}\), \(x_{p}\in X_{ij}\). \(u^{*}\) is the restoration pixel value, which is regarded as the final output. In order to preserve details or texture in image and overcome the weakness of median filters, we utilize weights from fuzzy inference. According to Equation (17), the filtering window's pixel values were multiplied by their associated weights to determine which degree of the pixel should be used to filter in the filtering process. The weight of pixel \(\omega_{p}\) represents the degree of the \(RefM_{i,j}\) with its immediate surroundings; as a result, it will be utilized to regulate the level of restoration that takes place. Pixel weight \(\omega_{p}\) indicates the level of importance of the pixel, and this characteristic decides how much useful information is needed for restoring. Finally, the restoring pixel value is obtained with the weighted mean as the final output and shown as Figure 6, in which the number with an underline means that the pixel is corrupted by noise. Figure 7 shows the noise corruption for a light region. Figure 8 shows the member function according to Equations (10) and (11) for shifting their location. Figure 9 shows the noise corruption for a dark region. Figure 10 is the member function according to Equations (10) and (11) for shifting their location. Figure 8: Input attribute function of Figure 7.  
Figure 9: Repair of darker areas (\(u^{*}=51\)).