# A Registration Method for Historical Maps Based on Self-Supervised Feature Matching
## 3 Materials and Methods
### Map Feature Matching Based on Graph Neural Networks  
A short introduction about the background of the Transformer, which is an encoder that relies on the attention mechanism, is given in [30]. The attention mechanism is a prevalent strategy in deep learning, particularly for tasks in natural language processing (NLP) and computer vision. When handling sequences, it concentrates on elements that are most pertinent to the current objective, thereby extracting essential information. The attention layer receives three input vectors: query Q, key K, and value V. The query vector Q accesses information from the key vector K by computing the dot product between Q and each corresponding key vector K, as illustrated by the following equation:  
\[Attention(Q,K,V)=\text{Softmax}(QK^{T})V \tag{1}\]  
Intuitively, attention acquires relevant information by calculating the similarity between each K and the Q. If the similarity is high, more relevant information will be extracted from V. This process is also referred to as message passing in graph neural networks.  
Historical map images often lack texture but exhibit strong local correlations. Similar building contours may appear within the same map, while maps from different periods may share spatially analogous configurations. To leverage these similarities, we construct a complete graph where nodes represent feature points from two encoded candidate sets. There are two types of undirected edges: the _intra-image_ edges, which are the connections between feature points of single image, and the _inter-image_ edges, which are the connections among feature points of the two input images. These edges define dual propagation mechanisms: _intra-image_ edges implement self-attention to model contextual relationships, whereas _inter-image_ edges facilitate cross-attention for correspondence reasoning.  
Let \({}^{(l)}can\_f_{i}^{A}\) denote the feature of the \(i\)-th candidate pixel in the reference image A at the \(l\)-th layer of the graph neural networks. This feature represents the aggregated information from other points \(\left\{j:(i,j)\in E\right\},\) where \(E\in\left\{\left.E_{\text{Intra}},E_{\text{Inter}}\right\}.\) Therefore, the update rule for \({}^{(l)}can\_f_{i}^{A}\) is given by Equation (2):  
\[{}^{(l+1)}can\_f_{i}^{A}=^{l}can\_f_{i}^{A}+MLP\left(\left[{}^{l}can\_f_{i}^{A }\parallel\mathit{mess}_{E\to i}\right]\right) \tag{2}\]  
In this process, \({}^{(l)}can\_f_{i}^{A}\) is concatenated with \(\mathit{mess}_{E\to i}\), two vectors. \(E\) denotes the type of edge through which information flows at the current layer. For layers \(1\sim L/2\), \(E=E_{\text{Intra}}\), and feature information is aggregated along the _intra-graph_ undirected edges towards the current feature. For layers \(L/2+1\sim L\), \(E=E_{\text{Inter}}\), and feature information is aggregated along the inter-graph undirected edges towards the current feature. \(\mathit{mess}_{E\to i}\) represents the aggregated information generated based on the attention mechanism:  
\[\alpha_{ij}=\text{Softmax}(Sim_{i}(query_{i},key_{i})) \tag{3}\]  
\[\mathit{mess}_{E\to i}=\sum_{j:(i,j)\in E}\alpha_{ij}value_{j} \tag{4}\]  
Let Q denote the query image and S denote the source information image. Due to the two types of information aggregation, namely, _intra-image_ and _inter-image_ aggregation, we define the following. Let the query vector \(query_{i}\) represent a linear mapping of the \(i\)-th pixel in the query Q, while the key vector \(key_{j}\) and value vector \(value_{j}\) represent linear mappings of the \(j\) feature point in the source information image S. The computation process for these vectors is given by the following equation:  
\[\mathit{query}_{i}=W_{1}.^{(l)}can\_f_{i}^{Q}+b_{1} \tag{5}\]  
\[\left[\begin{array}{c}key_{j}\\ value_{j