# A Registration Method for Historical Maps Based on Self-Supervised Feature Matching
## 3 Materials and Methods
### Optimal Transport  
Based on the feature vectors obtained in the previous section, we can compute the feature matching score matrix S for images A and B:  
\[S_{i,j}=\langle final\_f_{i}^{A},final\_f_{j}^{\beta}\rangle,\forall(i,j)\in A\times B \tag{8}\]  
where \(\langle\cdot,\cdot\rangle\) means the dot product operation. Each element in the matrix represents the similarity among candidate features in images A and B. At this point, we can transform the feature matching problem of images into the task of solving the assignment matrix X, such that the value of \(\sum_{i,j}S_{i,j}X_{i,j}\) is minimized. This is a classic optimal transport problem. Due to many points involved in the matching phase (typically, over 1000), the time cost must be optimized during the solution process. Therefore, we use an entropy-regularized algorithm to find an approximate solution [31]. We introduce an entropy regularization term:  
\[d_{S}^{\lambda}(r,c)=\min_{X\in U(r,c)}\sum_{i,j}S_{ij}X_{ij}-\varepsilon H(X) \tag{9}\]  
where \(\varepsilon\) is the regularization coefficient, and \(H(X)\) is the regularization. The latter is given by the following expression:  
\[H(X)=-\sum_{i,j}X_{ij}\left(\log\bigl{(}X_{ij}\bigr{)}-1\right) \tag{10}\]  
We use the Sinkhorn algorithm to iteratively solve for an approximate solution to this problem, ultimately obtaining the assignment matrix X. We apply RANSAC to eliminate mismatches, leveraging the planarity assumption that corresponding points between the two images lie on a shared plane explainable by a homography matrix. RANSAC follows a hypothesis-and-verification paradigm, iteratively refining model parameters. The algorithm initializes by assuming the data conform to a parametric model, randomly selecting minimal subsets to estimate provisional models. The consensus set is then evaluated by counting inliers--data points within a predefined error tolerance of the model. Inliers are defined as points satisfying the geometric constraint within a reprojection error threshold, whereas outliers violate this criterion. Models with larger consensus sets (i.e., higher inlier ratios) are probabilistically favored, as they maximize the likelihood of correct model estimation. Through iterative hypothesis generation and validation, RANSAC converges to the optimal model maximizing inlier count, while discarding residual outliers. In other words, all correctly matched point pairs between the two images to be registered can fit such a homography model. Therefore, RANSAC can be used to optimize the initial set of matched feature point pairs. The steps for using RANSAC to refine the initial feature match set in this study are as follows: (1) In the preliminary set of matched feature point pairs, define an initial homography transformation matrix as follows:  
\[ \begin{bmatrix}h_{11}&h_{12}&h_{13}\\ h_{21}&h_{22}&h_{23}\\ h_{31}&h_{32}&h_{33}\end{bmatrix}  \tag{11}\]  
Then, randomly sample at least four pairs of feature points and compute the homography transformation matrix H.  
\[s \begin{bmatrix}x^{\prime}\\ y^{{}^{\prime}}\\ 1\end{bmatrix} = \begin{bmatrix}h_{11}&h_{12}&h_{13}\\ h_{21}&h_{22}&h_{23}\\ h_{31}&h_{32}&h_{33}\end{bmatrix}\begin{bmatrix}x\\ y\\ 1\end{bmatrix}  \tag{12}\]Among them, \((x,y)\) denotes the coordinates of the feature points in the sensed image, whereas \((x^{{}^{\prime}},y^{{}^{\prime}})\) signifies the coordinates of the feature points in the reference image. Additionally, \(s\) represents the scaling parameter. Based on the homography transformation matrix, compute the reprojected coordinates of the features between two input images, then compare the distance between the reprojected point and its matching point in another map. If the distance falls below a pre-determined threshold, the pair is deemed a correct match, and the tally of accurate matches is incremented; otherwise, it is deemed a mismatch.