# A SqueezeSAR Spatially Adaptive Filtering Algorithm Based on Hadoop Distributed Cluster Environment
## 2 Spatial Adaptive Filtering Algorithm in Hadoop Environment  
### Spatial Adaptive Filtering Algorithm  
Theoretically, the InSAR interferometric phase \(\psi\) consists of several components, including the reference ellipsoidal phase \(\varphi_{ref}\), topographic phase \(\varphi_{top}\), deformation phase \(\varphi_{def}\), atmospheric phase \(\varphi_{atm}\), and noise phase \(\varphi_{noi}\), as follows. \[\psi=\varphi_{ref}+\varphi_{top}+\varphi_{def}+\varphi_{atm}+\varphi_{noi} \tag{1}\]  
The essence of obtaining the surface deformation of the entire study area is the process of obtaining the deformation phase \(\varphi_{def}\) by removing or suppressing the remaining phases. To reduce speckle noise in uniform areas (e.g., farmland and forests) with high SHP coverage without affecting point targets (e.g., buildings, boulders, etc. ), the optimal phase can be estimated by spatially simple averaging the phase values of the N(N\(-\)1)/2 pairs of the SHPs identified by the KS test, achieving an inverse performance with high deformation rate accuracy when the SHPs reach a certain number (25) [13]. The signal-to-noise ratio of the interferometric stripes can be significantly improved, at the cost of a reduced resolution, using simple spatial adaptive filtering. In Figure 1, we provide a comparison before and after filtering, and Figure 1a,b show the effect of the interferogram without and after filtering, respectively. It can be clearly seen that the noise in non-urban areas is significantly reduced. Moreover, as shown in Figure 2 and explicated using the DespecKS algorithm proposed in a previous study [13], only the SHP is averaged by spatial adaptive filtering, preserving the information associated with the point-by-point radar targets that are identified by the KS test as individual pixels (PS) and are therefore not affected by the filtering. By changing the phase value of the coherence matrix to the interferometric phase corresponding to spatial filtering, the phase optimization enables a better inversion of the surface deformation accuracy. The equation for spatial adaptive filtering is as follows:  
\[NL(i)=\frac{1}{n}\sum_{j\in\Omega}u(j) \tag{2}\]  
where \(i\) denotes the center pixel of the search window, \(n\) denotes the number of SHPs in the search window based on the KS test, and \(u(j)\) denotes the phase value of the SHP. To better understand the spatial adaptive filtering algorithm, we provide the pseudo-code for spatial adaptive filtering in Algorithm 1. The specific steps of spatial adaptive filtering are as follows:  
1. Read the phase information of the original N(N\(-1\))/2 interferograms. 2. The DS candidate points in the search window corresponding to a certain pixel are summed and considered as conforming if they are larger than the filtering threshold (25). 3. For each pixel that meets the requirement, all the phase values of the SHP in the window centered on it are summed and divided by the sum of the SHP, and the phase value of the center pixel is replaced by the average value. 4. Repeat Steps 2-3 until all pixels that meet the threshold requirements are replaced by the average phase value. ```
Input: Three-dimensional complex array interferogram phase values p[s,i,j].