# 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  
The algorithm we propose is akin to a switching median filter. This filter computes the local image from each picture pixel, rather than only utilizing the median to replace the noise, which is the main difference between our proposed novel method and this filter. More precisely, it utilizes standard deviation and fuzzy inference to estimate the restoration pixel value of the filtering window, where the output of fuzzy inference represents the importance of a pixel. For the above reasons, this filter method is called the AFWMF model in this study. The filtering started after the filtering order was determined as follows: let \(\rho_{i,j}^{(k)}\left(k=1\text{ }to\text{ }4,\text{ }w=2\right)\) be a set of four filtering windows directing pixels at one place (\(i\),\(j\)). This is defined as follows:  
\[ \begin{split}\rho_{i,j}^{(1)}&=\{x_{i-2,j-2},x_{i -1,j-1},x_{i,j},x_{i+1,j+1},x_{i+2,j+2}\},\\ \rho_{i,j}^{(2)}&=\{x_{i,j-2},x_{i,j-1},x_{i,j},x_{ i+1,j},x_{i,j+2}\},\\ \rho_{i,j}^{(3)}&=\{x_{i+2,j-2},x_{i+1,j-1},x_{i,j},x_{i-1,j+1},x_{i-2,j+2}\},\\ \rho_{i,j}^{(4)}&=\{x_{i-2,j},x_{i-1,j},x_{i,j},x_{ i+1,j},x_{i+2,j}\}.\end{split}  \tag{7}\]  
Figure 2: Structural flowchart of the proposed AFWMF model. Accordingly, the standard deviation of four filtering window directions is calculated as shown in Figure 3, and the standard deviation measures the degree of data dispersion [28]. \[\sigma_{i,j}^{k}=\sqrt{\frac{\sum_{\alpha=1}^{N}\left(\rho_{i,j}^{(\rho,k)}- \overline{\rho_{i,j}^{(k)}}\right)^{2}}{N-1}}\,\ k=1\ \text{to}\ 4, \tag{8}\]  
where \(\overline{\rho_{i,j}^{(k)}}\) is the mean value of \(\rho_{i,j}^{(k)}\) and \(N\) represents total number of elements in \(\rho_{i,j}^{(k)}\). Next, minimum standard deviation is formatted and given as follows:  
\[S_{i,j}=min\Big{\{}\ \sigma_{i,j}^{k}:\ k=1\ \text{to}\ 4\ \Big{\}}, \tag{9}\]  
where \(S_{i,j}\) means that one of the four directions is closest to each other in the same direction. Therefore, the central pixel value of the window should also be close to them in order to preserve the image detail or texture. For preserving detail or texture, we obtain a reference median from \(S_{i,j}\) called \(RefM_{i,j}\). It is formatted as Equation (10) below. \[RefM_{i,j}=median\big{\{}\ S_{i,j}\ \big{\}}. \tag{10}\]  
The standard deviation \(\sigma_{i,j}\) of local windows is defined using Equation (11) below. \[\sigma_{i,j}=\sqrt{\frac{\sum\ \left(X_{i,j}-\overline{X_{i,j}}\right)^{2}}{M-1 }},M=(2W+1)\times(2W+1), \tag{11}\]  
where \(\overline{X_{i,j}}\) is the mean value of \(X_{i,j}\). Afterwards, we form membership functions. There are three membership functions corresponding to three input fuzzy sets; they are nosie1, no-noise, and noise2, respectively, and are pictured in Figure 4. In Figure 4, the horizontal axis is a pixel value. On the vertical axis, the grade of membership of the element x in the fuzzy set is shown, with values ranging from 0 to 1. These three membership functions are three input fuzzy sets. They are formatted as Equations (12)-(14) below, respectively. \[\text{noise1}(x)=\left\{ \begin{array}{rl}1,&x\leq a_{in}\\ \frac{b_{in}-x}{b_{in}-a_{in}},&a_{in}\leq x\leq b_{in}\\ 0,&b_{in}\leq x\end{array} \right., \tag{12}\]  
Figure 3: Filter window and its main four directions. \[\text{no}-\text{nosie}(\text{x})=\left\{ \begin{array}{cc}0,&x\leq\text{a}_{ \text{in}}\\ \frac{x-\text{a}_{\text{in}}}{\text{b}_{\text{in}}-\text{a}_{\text{in}}},&\text {a}_{\text{in}}\leq x\leq\text{b}_{\text{in}}\\ 1,&\text{b}_{\text{in}}\leq x\leq\text{c}_{\text{in}}\\ \frac{\text{d}_{\text{in}}-\text{x}}{\text{d}_{\text{in}}-\text{c}_{\text{in}}},&\text{c}_{\text{in}}\leq x\leq\text{d}_{\text{in}}\\ 0,&\text{d}_{\text{in}}\leq x\end{array} \right., \tag{13}\]  
\[\text{nosie2}(x)=\left\{ \begin{array}{cc}0,&x\leq c_{in}\\ \frac{x-c_{in}}{a_{\text{in}}-c_{\text{in}}},&c_{in}\leq x\leq d_{in}\\ 1,&x\geq d_{in}\end{array}