# A New Adaptive Spatial Filtering Method in the Wavelet Domain for Medical Images
## 2 Materials and Methods
### Algorithm Proposed in This Work
By replacing \(w(1,n)\) with \(w_{new}(1,n)\) we will have the spatially filtered version of the first scale of the undecided wavelet transformation, a scale that actually contains most of the noise. This type of filter can be seen as a spatially dependent filter. The block diagram of the proposed algorithm is presented further in Figure 2 and is discussed in more detail in the subsequent paragraphs. The whole procedure can be described with the following algorithm:  
1. For each scale, from \(l\ =\ 1\ldots M\);
2. We determine the data set \(w_{new}(l,n)\), with the following iterative process:  
1. We compute \(Corr_{l}(l,n)\) and \(w(l,n)\)
2. We then compute the correlation and wavelet factors: \[PCorr_{l}(m)\ =\ \sum_{n}Corr_{l}^{2}(l,n)\] (10) \[PW(l)\ =\ \sum_{n}w^{2}(l,n)\] (11)  
Figure 2: Block diagram of the proposed algorithm. * We perform the scaling: \[Corr_{l}(m,n)\ =\ Corr_{l}(m,n)\cdot\sqrt{\frac{PW(m)}{PCorr_{l}(m)}}\ \text{for}\ n\ =\ 1\dots N.\] (12)
* We identify the contour location by verifying if the following condition is met: \[\big{|}Corr_{l}(m,n)\big{|}>\big{|}w(m,n)\big{|},\] (13) Additionally, for each location identified as a contour, we execute: \[\left\{ \begin{array}{c}w_{new}(m,n)\ =\ w(m,n)\\ w(m,n)\ =\ 0\\ Corr_{l}(m,n)\ =\ 0\end{array} \right.\] (14)
* We then test the stopping condition of the iterative process: \[PW(m)<\delta\] (15)  
In case of non-fulfillment of this condition the process is resumed from step B2, and in case of fulfillment of the condition it is passed to the next scale (step B). At the end of this procedure, in \(w_{new}(m,n)\), we have the filtered values of the wavelet coefficients, corresponding to the undecimal wavelet transform of the estimated signal. We tested the proposed procedure for noise reduction from images obtained from medical applications, using a three-level wavelet development (\(l=2\)), which corresponds to 8 sub-bands. The results obtained by this method were compared with results obtained by Wiener filtration. It was thus observed that the images filtered by the proposed method are affected by less noise, better contoured and do not show artifacts generated by the Gibbs effect or other artifacts and have a better visual quality compared to images filtered with Wiener filter. Maintaining the idea of punctually establishing the threshold value and exploiting inter-band dependence by determining a map of accounts using the concept of hierarchical, we propose a new spatial adaptive filter. The proposed algorithm has 3 stages. In the first stage, the threshold values for each coefficient, necessary for the soft truncation of the wavelet coefficients, are determined based on the local statistics. The difference from the method set out in the previous paragraph is primarily in simplifying the determination of local signal dispersion. For this we discard the selection of the coefficients used to determine the signal dispersion based on the random variable \(z\), taking into account all wavelet coefficients contained in a given window, but which has much smaller dimensions and we discard the use of the parent coefficient used to evaluate local dispersion. In this case, the local dispersion corresponding to the \(w(i,j)\) coefficient will be given by:  
\[\hat{\sigma}_{x}^{2}(i,j)\ =\ max\big{(}\sigma_{s}^{2}-\sigma^{2},0\big{)} \tag{16}\]  
where:  
\[\sigma_{s}^{2}(i,j)\ =\ \frac{1}{M}\sum_{k,l\in B(i,j)}w^{2}(k,l) \tag{17}\]  
\(B(i,j)\) being the set of indices of the coefficients in the current window, and \(M\) is the number of coefficients contained in the window. The current threshold value will be given by:  
\[\hat{\lambda}(i,j)\ =\ \frac{\sigma^{2}}{\hat{\sigma}_{x}(i,j)} \tag{18}\]  
Furthermore, in this stage, the contour map is determined based on the hierarchical correlation corresponding to the degraded image.