## 2 Methods
### Instrument Scale Recognition Method
#### 2.2.2 Dial Tilt Correction  
If a disparity exists between the long and short axes of the inner dial contour, it indicates that the dial is tilted to varying degrees. To ensure the accuracy of subsequent scale recognition, it is necessary to perform a perspective transformation on the tilted dial to correct its alignment. Perspective transformation involves using matrix multiplication to project the original two-dimensional image into three-dimensional space and then map it onto a new two-dimensional plane. The perspective transformation process is depicted in Figure 5.  
The specific method is as follows: extend the original image coordinates with a z-coordinate to perform perspective transformation in three-dimensional space, and assume (\(z_{i}^{\prime}=z_{i}=1\)), which means that the spatial operation before and after remains on the plane (\(z=1\)). The working principle is shown in Figure 5a, and the perspective transformation formula is as  
\[\begin{bmatrix}x_{i}^{\prime}\\ y_{i}^{\prime}\\ 1\end{bmatrix}=T\begin{bmatrix}x_{i}^{\prime}\\ y_{i}\\ 1\end{bmatrix}=\begin{bmatrix}t_{11}&t_{12}&t_{13}\\ t_{21}&t_{22}&t_{23}\\ t_{31}&t_{32}&t_{33}\end{bmatrix}\begin{bmatrix}x_{i}^{\prime}\\ y_{i}\\ 1\end{bmatrix} \tag{1}\]  
i.e.,  
\[\begin{array}{l}x_{i}^{\prime}=\frac{t_{11}x_{i}+t_{12}y_{i}+t_{13}}{t_{13}x _{i}+t_{23}y_{i}+t_{33}}\\ y_{i}^{\prime}=\frac{t_{12}x_{i}+t_{23}y_{i}+t_{23}}{t_{13}x_{i}+t_{33}}\\ \end{array} \tag{2}\]  
Figure 5: Perspective Transformation. (**a**) Principle of perspective transformation; (**b**) Four sets of corresponding coordinate points.  
assume \(t_{33}=1\),  
\[\begin{array}{c}t_{11}x_{i}+t_{12}y_{i}+t_{13}-t_{31}x_{i}x_{i}^{\prime}-t_{32}y _{i}x_{i}^{\prime}=x_{i}^{\prime}\\ t_{21}x_{i}+t_{22}y_{i}+t_{23}-t_{31}x_{i}y_{i}^{\prime}-t_{32}y_{i}y_{i}^{ \prime}=y_{i}^{\prime}\end{array} \tag{3}\]  
Obtains the coordinate information of the endpoints of the major and minor axes retained from the ellipse fitting process, as well as the coordinate information for the corresponding points on the major and minor axes after the perspective transformation into a circle, as shown in Figure 5b. By substituting these into equation (3), the transformation matrix \(T\) yielding:  
\[T=\begin{bmatrix}t_{11}&t_{12}&t_{13}\\ t_{21}&t_{22}&t_{23}\\ t_{31}&t_{32}&t_{33}\end{bmatrix}=\begin{bmatrix}T_{1}&T_{2}\\ T_{3}&t_{33}\end{bmatrix} \tag{4}\]  
where \(T_{1}\) denotes the image linear transformation, \(T_{2}\) is used for generating the image perspective transformation, and \(T_{3}\) represents the image translation. By substituting the computed transformation matrix \(T\) into equation (2), the resulting data of the dial coordinates after perspective transformation are obtained, yielding a corrected circular dial as shown in Figure 6, thereby achieving the rectification of the inclined instrument dial. Perspective transformation may lead to significant offset of the dial position in the corrected image and the scale not being centered. The counting rectangular frame in the dial can be detected and extracted, and an affine transformation can be applied to it to deduce the rotation angle. Subsequently, the dial is corrected for rotation based on the calculated rotation angle for subsequent image analysis or processing.