# Sub-Pixel Displacement Measurement with Swin Transformer: A Three-Level Classification Approach
## 3 Swin Transformer-Based Sub-Pixel Displacement Measurement Method
### Three-Level Classification Method for Calculating Sub-Pixel Displacement  
For a positive sub-pixel displacement X belonging to the range of [0, 0.999], it can be decomposed into the form shown in Equation (1):  
\[X=\alpha\times 0.1+\beta\times 0.01+\gamma\times 0.001 \tag{1}\]  
where \(\alpha,\beta,\) and \(\gamma\) are integers between 0 and 9, respectively. The tasks of the three-level classification structure of F-ST, S-ST, and T-ST of the ST-SDM are to obtain the three coefficients \(\alpha,\beta,\) and \(\gamma\) using the Swin Transformer structure, respectively. Thus, there will be 10 categories at each level of classification, which are 0, 1, 2,..., and 9. Specifically, in the first level classification task, F-ST, the coefficient \(\alpha\) will be obtained, and the value of \(\alpha\) is an integer between 0 and 9, which represents 10 classifications, each of which represents a sub-pixel displacement value within [0, 0.9], i.e., class 0 represents 0 pixels, class 1 represents 0.1 pixels, class 2 represents 0.2 pixels, and so on, and class 9 represents 0.9 pixels. In the second level classification task, S-ST, the coefficient \(\beta\) will be obtained, and the value of \(\beta\) is an integer between 0 and 9, indicating 10 categories, each representing a sub-pixel displacement value within [0, 0.09], i.e., class 0 represents 0 pixels, class 1 represents 0.01 pixels, class 2 represents 0.02 pixels, and so on, and class 9 represents 0.09 pixels. In the third level classification task, T-ST, the coefficient \(\gamma\) will be obtained, and the value of \(\gamma\) is an integer between 0 and 9, indicating 10 categories, each representing a sub-pixel displacement value within [0, 0.009], i.e., class 0 represents 0 pixels, class 1 represents 0.001 pixels, class 2 represents 0.002 pixels, and so on, and class 9 represents 0.009 pixels.  
Equation (1) is optimally designed for hierarchical sub-pixel displacement estimation. By aligning with the decimal system, it ensures unique and complete coverage of the range [0, 0.999] through three progressive stages: coarse (\(\alpha\), tenths), medium (\(\beta\), hundredths), and fine (\(\gamma\), thousandths) adjustments. This structure inherently supports precision hierarchy, where each Swin Transformer-based classification level (F-ST, S-ST, T-ST) independently resolves displacements at distinct orders of magnitude, avoiding scale overlap or ambiguity. The use of 10 integer classes (0-9) per level guarantees computational tractability, mirroring  
Figure 3: Architecture of the proposed ST-SDM. “Ref” means reference images, “F-ST” means the first-level classification, “S-ST” means the second-level classification, “T-ST” means the third-level classification, and “Tar”, “Tar2”, and “Tar3” represent the input target images for the three levels of classification, respectively.  
digit-classification frameworks while maintaining a deterministic one-to-one mapping between displacement values and coefficients. Compared to irregular decompositions (e.g., 0.05/0.005 intervals), and this approach eliminates redundancy, ensures full-range coverage, and aligns seamlessly with the hierarchical feature extraction capabilities of Swin Transformers, enhancing both training stability and interpretability.  
In this way, for a sub-pixel displacement value of 0.106 pixels, the classification label obtained from F-ST, S-ST, and T-ST should be \"1\", \"0\", and \"6\", respectively. For a negative sub-pixel displacement, each level of classification will directly output the category \"0\". However, this displacement value can still be obtained by the approach described in the next subsection. The advantage of using a three-level categorization task is that although there are only 10 categories at each level of categorization, 1000 categories can actually be obtained.