## 2 Image Registration Algorithm Based on Deep Learning and Local Homography Transformation
### Direct Linear Transformation (DLT)  
If there is no parallax between the reference and target images, the mapping relationship between the two images is simple homographic, which can be described by the homography matrix. Suppose that two points with coordinates \(\mathbf{x}^{\prime}=\left[x^{\prime},y^{\prime}\right]^{\mathrm{T}}\) and \(\mathbf{x}=\left[x,y\right]^{\mathrm{T}}\) are the corresponding matching points on the reference image \(I^{\prime}\) and the target image \(I\) respectively, and the corresponding relationship between these two points can be expressed as  
\[\mathbf{\overline{x}^{\prime}}=\mathbf{H\overline{x}} \tag{1}\]  
where \(\mathbf{\overline{x}^{\prime}}\) and \(\mathbf{\overline{x}}\) are the homogeneous coordinates of the two points respectively, and \(\mathbf{\overline{x}^{\prime}}=\left( \begin{array}{c}x^{\prime\prime}\\ y^{\prime\prime}\\ z^{\prime\prime}\end{array} \right)\)  
\[\mathbf{\overline{x}}=\left( \begin{array}{c}x\\ y\\ 1\end{array} \right)\mathbf{H}\text{ is the homography matrix between the two images, }\mathbf{H}=\left( \begin{array}{ c c}h_{11}&h_{12}&h_{13}\\ h_{21}&h_{22}&h_{23}\\ h_{31}&h_{32}&h_{33}\end{array} \right).\]In the non-homogeneous coordinates, the corresponding relationship between matching points \(\mathbf{x}\) and \(\mathbf{x^{{}^{\prime}}}\) can be expressed as  
\[x^{\prime}=\frac{x^{\prime\prime}}{z^{\prime\prime}}=\frac{h_{11}x+h_{12}y+h_{13 }}{h_{31}x+h_{32}y+h_{33}}\ y^{\prime}=\frac{y^{\prime\prime}}{z^{\prime\prime }}=\frac{h_{21}x+h_{22}y+h_{23}}{h_{31}x+h_{32}y+h_{33}} \tag{2}\]  
Transform Equation (1) into the form of \(0_{3\times 1}\mathbf{=}\mathbf{\overline{x^{{}^{\prime}}}}\times\mathbf{H \overline{x}}\) and obtain  
\[\left( \begin{array}{c}0\\ 0\\ 0\end{array} \right)=\left( \begin{array}{ccccccccc}0&0&0&-x&-y&-1&xy^{\prime }&yy^{\prime}&y^{\prime}\\ x&y&1&0&0&0&-xx^{\prime}&-yx^{\prime}&-x^{\prime}\\ -xy^{\prime}&-yy^{\prime}&-y^{\prime}&xx^{\prime}&yx^{\prime}&x^{\prime}&0&0 &0\end{array} \right)\mathbf{h} \tag{3}\]  
where \(\mathbf{h}=(h_{11}\ h_{12}\ h_{13}\ h_{21}\ h_{22}\ h_{23}\ h_{31}\ h_{32}\ h_{33})^{ \mathrm{T}}\). When estimating \(\mathbf{H}\), more matching point information can be used to reduce the estimation error In Equation (3), only two rows of the \(3\times 9\) coefficient matrix on the right side of the equation are independent. By selecting the first two rows to form an independent coefficient matrix \(\mathbf{A}_{i}\), and taking all matching points into account, a \(2N\times 9\) coefficient matrix \(\mathbf{A}\) can be formed. By using the least square method, the solution of \(\mathbf{h}\) can be expressed as  
\[\mathbf{\hat{h}}=\underset{\mathbf{h}}{\mathrm{argmin}}\sum_{i=1}^{N}\| \mathbf{A}_{i}\mathbf{h}\|^{2}=\underset{\mathbf{h}}{\mathrm{argmin}}\| \mathbf{A}\mathbf{h}\|^{2} \tag{4}\]  
where \(\mathbf{\hat{h}}\) is an estimation of \(\mathbf{h}\), \(\|\mathbf{A}\mathbf{h}\|\) denotes the two norms of vector \(\mathbf{A}\mathbf{h}\), \(\mathbf{h}\) is the normalized unit vector, \(N\) denotes the total number of pairs of matching points, and \(\mathbf{A}_{i}\) denotes the independent coefficient matrix corresponding to the \(i\)th pair of matching points. Singular value decomposition (SVD) can be used to calculate \(\mathbf{\hat{h}}\). The right singular vector corresponding to the minimum singular value of \(\mathbf{A}\) is the result. The estimation of homography matrix \(\mathbf{H}\) is obtained by arranging the elements of vector \(\mathbf{\hat{h}}\) in a certain order. Considering that SVD is time-consuming, which will affect the training speed of the neural network, Equation (3) is transformed into the form of non-homogeneous linear least squares.