## 3 Our Approach
### Hash Adaptive Matching Module  
Inspired by SISR self-similarity technology [29], we introduce self-similarity information within LR images based on the similarity calculation between LR images and Ref images. By combining the similarities within and between images, a hash adaptive matching (HAM) method is proposed to enhance the accuracy of matching, thereby more effectively guiding the super-resolution reconstruction process and achieving higher-quality image detail restoration. In order to facilitate the calculation of global attention, the features of the input LR and Ref images \(F_{LR}=R^{h\times w\times c}\) and \(F_{Ref}=R^{h\times w\times c}\) are first reshaped into one-dimensional feature vectors \(F_{LR}^{\prime}=R^{htw\times c}\) and \(F_{Ref}^{\prime}=R^{htw\times c}\). The traditional non-local attention mechanism requires a similarity calculation between all feature vectors pair-wise, which is computationally intensive. To reduce the complexity of this process, the HAM method uses the spherical hash partition (SHP) strategy [30]. This strategy divides the feature space based on the angular distance relationship between features, aggregates similar features into the same hash bucket, and performs attention calculation only in locally relevant regions. Specifically, as shown in Figure 2, the basic idea of SHP is to nest a polyhedral structure within a unit sphere, use a hash function to map the eigenvectors to the outer surface of the sphere, and randomly rotate the polyhedral structure to ensure that the mapping process has sufficient randomness and directional coverage. Each feature vector selects the nearest vertex as its final hash index based on its angle with the vertices of the polyhedron. If the directions of two feature vectors are similar, that is, the angle between them is small, then they will be classified into the same hash bucket and identified as highly correlated features. Among them, the random rotation matrix has independent and identically distributed Gaussian components, ensuring the independence and uniformity of each hash mapping process in terms of direction. To obtain m hash buckets, we must first project the target tensor onto a hypersphere and randomly rotate it using a matrix. The process of random rotation is as follows:  
\[\hat{x}=R(\frac{x}{\left\|x\right\|}_{2}), \tag{1}\]  
Here, \(R\) is a size matrix \(c\times m\), \(c\) represents the dimension of input features, and \(m\) represents the number of hash buckets. Each element is an independent Gaussian variable\(N\) (0,1) sampled from below. This matrix is used to randomly project input features and is not strictly a rotation matrix. Map the feature vector \(x\) onto the sphere to obtain \(x^{\prime}\). The hash computation process is as follows:  
\[h(x)=\text{argmax}_{i}(\hat{x}), \tag{2}\]  
The hash code is defined as \(h(x)\). After performing hash computation on all feature tensors, obtain multiple hash buckets, we need to divide the space into buckets of related elements, so we calculate the similarity within each bucket. \(\delta_{i}\) represents the index of the bucket:  
\[\delta_{i}=\big{\{}h(x_{j})=h(x_{i})\big{\}}, \tag{3}\]  
Here, \(i\) represents each feature tensor, \(\delta_{i}\) is the index, and \(j\) denotes the global feature. The hash results are sorted and partitioned into blocks, each containing a fixed number of feature tensors, with an attention range defined for each block. The attention mechanism extends beyond block boundaries to incorporate adjacent regions. To address the issue of relevant features being dispersed into different buckets, multiple independent hash operations are performed, and their results are aggregated to minimize the error probability.