## 2 Image Alignment
### Perspective Transform  
Perspective transforms project a picture onto a new plane of view and are commonly used for distortion correction of images. The alignment of an image is essentially a distortion-correcting process for specified feature points. The lining surface studied in this paper can be approximated as a plane, and the captured image can be regarded as a single depth-of-field image. Therefore, the pixel alignment of the infrared image and the visible image is realized using the transmission transform. We select four mapping pairs to compute the perspective transform matrix \(\mathbf{T}\). To decrease the error, the four points with the largest encircled area are selected for the computation. Let the coordinates of the source and target images in the four selected matching pairs be denoted as (\(x_{k}\), \(y_{k}\)) and (\(x^{\prime}_{k}\), \(y^{\prime}_{k}\)), respectively, with \(k=1\), \(2\), \(3\), and \(4\). According to the mapping relation of the perspective transformation, the position of the target image can be calculated by the following matrix equation:  
\[\begin{bmatrix}x_{1}&y_{1}&1&0&0&0&-x_{1}x^{\prime}_{1}&-y_{1}x^{\prime}_{1}\\ 0&0&0&x_{1}&y_{1}&1&-x_{1}y^{\prime}_{1}&-y_{1}y^{\prime}_{1}\\ x_{2}&y_{2}&1&0&0&0&-x_{2}x^{\prime}_{2}&-y_{2}x^{\prime}_{2}\\ 0&0&0&x_{2}&y_{2}&1&-x_{2}y^{\prime}_{2}&-y_{2}y^{\prime}_{2}\\ x_{3}&y_{3}&1&0&0&0&-x_{3}x^{\prime}_{3}&-y_{3}x^{\prime}_{3}\\ 0&0&0&x_{3}&y_{3}&1&-x_{3}y^{\prime}_{3}&-y_{3}y^{\prime}_{3}\\ x_{4}&y_{4}&1&0&0&0&-x_{4}x^{\prime}_{4}&-y_{4}x^{\prime}_{4}\\ 0&0&0&x_{4}&y_{4}&1&-x_{4}y^{\prime}_{4}&-y_{4}y^{\prime}_{4}\\ \end{bmatrix}\begin{bmatrix}t_{11}\\ t_{12}\\ t_{13}\\ t_{21}\\ t_{22}\\ t_{32}\\ t_{31}\\ t_{32}\\ t_{31}\\ t_{32}\\ t_{33}\\ t_{4}\\ t_{32}\\ t_{4}\\ \end{bmatrix}=\begin{bmatrix}x^{\prime}1\\ y^{\prime}_{1}\\ x^{\prime}2\\ y^{\prime}_{2}\\ x^{\prime}3\\ y^{\prime}_{3}\\ x^{\prime}4\\ y^{\prime}_{4}\\ \end{bmatrix} \tag{4}\]  
where the left-hand side of the equation and the first term on the right-hand side of the equation are known matrices, so the second term on the right-hand side of the equation can be solved using Gaussian elimination or LU decomposition. Form the transformation matrix \(\mathbf{T}\) according to the solution result of Equation (4), where \(t_{ij}\) is the element of the \(i\)th row and \(j\)th column of the transformation matrix \(\mathbf{T}\), and \(t_{33}=1\). Using the transformation matrix \(\mathbf{T}\), any point (\(x,y\)) in the source image can be mapped to the intermediate variables (\(x_{i}^{\prime}\), \(y_{t}\), \(z_{i}^{\prime}\)), which represent the position of the target image through the transformation matrix. The transformation equation is  
\[\begin{bmatrix}x_{t}\\ y_{t}\\ z_{t}\end{bmatrix}=\mathbf{T}\begin{bmatrix}x\\ y\\ 1\end{bmatrix},\mathbf{T}=\begin{bmatrix}t_{11}&t_{12}&t_{13}\\ t_{21}&t_{22}&t_{23}\\ t_{31}&t_{32}&t_{33}\end{bmatrix} \tag{5}\]  
Then, the normalization operation \(x^{\prime}=x_{t}/z_{t}\), \(y^{\prime}=y_{t}/z_{t}\) is performed to obtain the mapped position coordinates (\(x^{\prime}\), \(y^{\prime}\)), and the pixel values of the integer position coordinates are obtained after bilinear interpolation.