# Expanded Scene Image Preprocessing Method for the Shack-Hartmann Wavefront Sensor
## 2 Methods  
### Principles of Wavefront Detection for Extended Target Shack-Hartmann Wavefront Sensors  
Since extended targets are imaged against the same target, each subaperture image is virtually the same. When the incident wavefront is subjected to wavefront disruption, the position of the subaperture image is comparatively moved. The offset of the subaperture picture is determined by the mutual correlation method as a reference image when there is no distortion, and parabolic interpolation is carried out in the vicinity of its peak-maximum location to obtain subpixel level accuracy [26; 27; 28]. To locate the peak, the mutual correlation approach uses the normalized mutual correlation function as a criterion for picture alignment. Equation (1) below illustrates the calculation for the normalized mutual correlation function:  
\[\mathrm{r}_{sr}(x_{0},y_{0})=\frac{\sum\limits_{x=1}^{M}\sum\limits_{y=1}^{M}I _{s}(x+x_{0},y+y_{0})I_{r}(x,y)}{\sqrt{\sum\limits_{x=1}^{M}\sum\limits_{y=1} ^{M}I_{s}^{2}(x+x_{0},y+y_{0})\times\sum\limits_{x=1}^{M}\sum\limits_{y=1}^{M }I_{r}^{2}(x,y)}}, \tag{1}\]  
where the size of the reference image is \(M\times M\) pixels, \(I_{r}(x,y)\) and \(I_{s}(x,y)\) denote the gray values of the reference image and the aberrated image at \((x,y)\), respectively, and \((x_{0},y_{0})\) is regarded as the offset of the subaperture image in both directions. The peak value of the cross-correlation function is obtained when the similarity between the subaperture images of the reference image and the distorted image is maximum. The offsets of the subaperture images usually need to be interpolated to subpixel accuracy. The parabolic interpolation method adopted is shown in Equation (2):  
\[ \begin{split} x_{0}&=\Delta_{x}+\frac{0.5[C\big{(} \Delta_{x}-1,\Delta_{y}\big{)}-C\big{(}\Delta_{x}+1,\Delta_{y}\big{)}]}{C\big{(} \Delta_{x}-1,\Delta_{y}\big{)}+C\big{(}\Delta_{x}+1,\Delta_{y}\big{)}-2C\big{(} \Delta_{x},\Delta_{y}\big{)}}\\ y_{0}&=\Delta_{y}+\frac{0.5[C\big{(}\Delta_{x}, \Delta_{y}-1\big{)}-C\big{(}\Delta_{x},\Delta_{y}+1\big{)}]}{C\big{(}\Delta_{ x},\Delta_{y}-1\big{)}+C\big{(}\Delta_{x},\Delta_{y}+1\big{)}-2C\big{(} \Delta_{x},\Delta_{y}\big{)}}\end{split} \, \tag{2}\]  
where \(\big{(}\Delta_{x},\Delta_{y}\big{)}\) is the whole-pixel precision of the peak of the intercorrelation. Substituting \((x_{0},y_{0})\) into the average slope \((\hat{G}_{x},\hat{G}_{y})\) of the subaperture image, it is calculated as shown in Equation (3) below:  
\[\left\{ \begin{array}{c}\hat{G}_{x}=\frac{x_{0}}{f}\\ \hat{G}_{y}=\frac{\hat{G}_{0}}{f}\end{array} \right., \tag{3}\]  
where \(f\) is the focal length of the microlens. After deriving the slope, the wavefront is reconstructed using the mode method. In the mode method wavefront reconstruction method, the incident wavefront can be described by a set of Zernike polynomials, which are computed as shown in Equation (4) below:  
\[\Phi(x,y)=a_{0}+\sum\limits_{k=1}^{n}a_{k}Z_{k}(x,y)+\varepsilon, \tag{4}\]  
where \(\Phi\) is the incident beam wavefront, \(a_{0}\) is the mean phase wavefront, \(a_{k}\) is the \(k\)-term Zernike polynomial coefficient, \(Z_{k}\) is the k-term Zernike polynomial, and \(\varepsilon\) is the wavefront phase measurement error. The expression for the slope of the subaperture image in the extended target Shack-Hartmann wavefront sensor is shown in Equation (5) below. \[\left\{ \begin{array}{c}G_{X}(i)=\sum\limits_{k=1}^{n}a_{k}\frac{dxdy}{S_{i}} +\varepsilon_{x}\\ =\sum\limits_{k=1}^{n}a_{k}Z_{\text{x}k}(i)+\varepsilon_{x}\\ G_{Y}(i)=\sum\limits_{k=1}^{n}a_{k}\frac{dxdy}{S_{i}}+\varepsilon_{y}\\ =\sum\limits_{k=1}^{n}a_{k}Z_{\text{y}k}(i)+\varepsilon_{y}\end{array}