## 2 Image Registration Algorithm Based on Deep Learning and Local Homography Transformation
### Sample and Label Generation Method Based on Local Homography Transformation
Then transform the \(M\times N\) uniform grid points \(G_{A}\) into new points \(G^{\prime\prime}{}_{A}\) by using \(\mathbf{H}_{S}^{AB}\) and calculate the root mean square error (RMSE) between \(\widetilde{G}^{\prime}{}_{A}\) and \(G^{\prime\prime}{}_{A}\). After that, divide the original image \(I_{A}\) into an \(m\times n\) uniform grid according to the RMSE, as shown in Figure 1e. If the RMSE is large, which means that there is a strong locality between \(G_{A}\) and \(\widetilde{G}^{\prime}{}_{A}\), the grid of the original image should be partitioned smaller to improve the local accuracy; conversely, if the RMSE is small, it means that the local homography matrixes have strong global character, therefore, the grid of the original image can be partitioned larger so as to speed up sample generation. The number of rows and columns of the uniform grid can be determined by  
\[m=\text{int}\left(\text{min}\left(1+\frac{H\cdot y_{mse}}{\rho^{\prime}{}_{y }^{\prime}\text{h}_{\text{min}}},\;\frac{H}{h_{\text{min}}}\right)\right),\quad n =\text{int}\left(\text{min}\left(1+\frac{W\cdot x_{mse}}{\rho^{\prime}{}_{x} ^{w}\text{min}},\;\frac{W}{w_{\text{min}}}\right)\right) \tag{16}\]  
where \(m\) and \(n\) are the number of rows and columns of the uniform grid, \(W\) and \(H\) are the width and height of the image \(I_{A}\), \(x_{mse}\) and \(y_{mse}\) represent the RMSE between \(\widetilde{G}^{\prime}{}_{A}\) and \(G^{\prime\prime}{}_{A}\) in horizontal and vertical directions, and \(w_{\text{min}}\) and \(h_{\text{min}}\) represent the minimum width and minimum height of each image block, respectively. \(w_{\text{min}}\) and \(h_{\text{min}}\) should not be too small, otherwise, it will cause too many blocks of some samples, which will affect the speed of sample generation; however, it also should not be too large, so as to avoid too few blocks of samples, which will result in an unnatural block effect in the transformed image. Step 6: Calculate the local homography matrix \(\mathbf{H}_{j}^{AB}\) (\(j=1,2,\cdots,m\times n\)) corresponding to each block of the \(m\times n\) uniform grid with the MDLT algorithm, in which the \(M\times N\) pairs of corresponding points between \(G_{A}\) and \(\widetilde{G}^{\prime}{}_{A}\) are used as the pairs of matching points, so that the \(m\times n\) local homography matrixes \(\mathbf{H}_{L}^{AB}=\left\{\mathbf{H}_{j}^{AB}\middle|j=1,2,\cdots,m\times n\right\}\) are obtained. Then transform the original image \(I_{A}\) into a new image \(I_{B}\) with \(\mathbf{H}_{L}^{AB}\) and calculate the coordinate of the points \(G_{B}\) in image \(I_{B}\) corresponding to \(G_{A}\) in \(I_{A}\) with \(\mathbf{H}_{L}^{AB}\). Figure 1f shows the image \(I_{B}\) generated from the original image \(I_{A}\) shown in Figure 1a after local homography transformation, and the grid points  
The calculation of the overlap degree of two sample images is illustrated in Figure 1h. Let \(I^{\prime\prime}{}_{A}\) be the corresponding binary mask of sample image \(I^{\prime}{}_{A}\) in the original image \(I_{A}\). Transform the mask image \(I^{\prime\prime}{}_{A}\) through the local homography matrix \(\mathbf{H}_{L}^{AB}\) so as to obtain the corresponding binary mask \(I^{\prime\prime}{}_{B}\) in the image \(I_{B}\). Then the binary mask images \(I^{\prime\prime}{}_{A}\) and \(I^{\prime\prime}{}_{B}\) are intersected to get the binary mask image \(I^{\prime\prime}{}_{AB}\), in which the non-zero-pixel region indicates the overlap region of the two sample images, as shown in Figure 1h. Thus, the overlap degree of two sample images is calculated as  
\[\partial=\frac{S_{AB}}{S_{A}} \tag{17}\]  
where \(\partial\) denotes the overlap degree, \(S_{A}\) denotes the number of non-zero pixels in \(I^{\prime\prime}{}_{A}\), and \(S_{AB}\) denotes the number of non-zero pixels in \(I^{\prime\prime}{}_{AB}\). If \(\partial\) of two sample images is lower than a threshold, the two sample images will be discarded.