# Line Matching Based on Viewpoint-Invariance for Stereo Wide-Baseline Aerial Images
## Image Rectification Using a Perspective Transformation Model
### Perspective Transformation Matrix's Solution and Image Correction  
According to the central perspective projection model in computer vision, the relationship of digital conversion between image points and 3D points in the object space is related by the projection matrix \(\mathbf{P}\)[25]:  
\[\lambda\widetilde{x}=\mathbf{P}\widetilde{X}=\mathbf{K}[\mathbf{R}_{\mathbf{c}}|t]\widetilde{X }=\mathbf{K}[\mathbf{R}_{\mathbf{c}}|-\mathbf{R}_{\mathbf{c}}C]\widetilde{X} \tag{3}\]  
For the aerial data used in this paper, the object coordinate system is a geodetic coordinate system expressed in terms of longitude, latitude, and altitude. Therefore, the \(Z\)-axis is perpendicular to the local geoid. Since ground buildings are generally vertical (parallel to the \(Z\) axis), top surfaces of many buildings are approximately parallel to the geoid. Therefore, we consider choosing the local geoid as the projection plane, and to conduct perspective transformation with the original image according to the Equation (4) in order to obtain a new image. Equation (4) is simplified below. The perspective projection matrix is a 3-4 matrix. So, define \(P=\left[ \begin{array}{cccc}P_{1}&P_{2}&P_{3}&P_{4}\end{array} \right]^{T}\), then Equation (4) can be expressed as:  
\[\lambda\left[ \begin{array}{c}u\\ v\\ 1\end{array} \right]=\left[ \begin{array}{cccc}P_{1}&P_{2}&P_{3}&P_{4}\end{array}  \right]\left[ \begin{array}{c}X\\ Y\\ Z\\ 1\end{array} \right] \tag{5}\]  
Since the object projection plane is a geoid, its elevation is 0, that is, \(Z=0\). Consequently, the above formula becomes:  
\[\lambda\left[ \begin{array}{c}u\\ v\\ 1\end{array} \right]=\left[ \begin{array}{cccc}P_{1}&P_{2}&P_{4}\end{array}  \right]\left[ \begin{array}{c}X\\ Y\\ 1\end{array} \right] \tag{6}\]  
Equation (6) gives the perspective transformation relationship between the image plane and the object space plane, which are consistent with the Equation (3). Let \(M=\left[ \begin{array}{cccc}P_{1}&P_{2}&P_{4}\end{array} \right]\), then the transformation relationship between an image point on the original image and the corresponding image point on the transformed image can be expressed as follows:  
\[\lambda\left[ \begin{array}{cccc}u&v&1\end{array} \right]=\mathbf{M}\cdot\left[ \begin{array}{cccc}u\prime&v\prime&1\end{array} \right] \tag{7}\]  
Since the \(Z\) value is customized, the resolution size of the rectified image obtained through the above transformation is very different from that of the original image. In order to ensure the consistency of the scale, a scale matrix needs to be found. It is assumed that \(W\) and \(H\) are the width and height of the original image along-with the coordinates of its four vertices \((0,0)\), \((0,H)\), \((W,H)\), \((W,0)\), respectively. The effective content of the rectified image obtained through transformation is an approximate trapezoid whose corresponding vertex coordinates are \((u\prime_{i},v\prime_{i})(i=1,2,3,4)\). Upon finding the minimum value \(u\prime_{\text{min}}\) and maximum value \(u\prime_{\text{max}}\) of the four \(u\) values, the scale factor can be obtained:  
\[s=(u\prime_{\text{max}}-u\prime_{\text{min}})/W \tag{8}\]  
The scale-adjusted perspective transformation matrix is:  
\[\mathbf{M}_{5}=\mathbf{M}\cdot\left[ \begin{array}{cccc}s&0&0\\ 0&s&0\\ 0&0&1\end{array} \right] \tag{9}\]  
Now, the conversion relationship between the original image and the rectified image can be finally established through following Equation:  
\[I^{\prime}=\mathbf{M}_{5}{}^{-1}\cdot I \tag{10}\]  
where \(I\) is the original image and \(I^{\prime}\) is the rectified image using perspective transformation.