# Calibration and Image Reconstruction in a Spot Scanning Detection System for Surface Defects
## 3 System Calibration and Image Reconstruction Methods
### Modeling of the Practical Scanning Trace  
Figure 4 presents the schematic of practical system state at initial time (\(t=0\)) and scanning time \(t\). With the help of this figure, this section will parameterize the system deviations described above and finally derive the coordinate of the illuminated spot \(p(t)\) to establish a mathematical model of the practical scanning trace of the SS-SDES. According to the definition of the system coordinate system, the rotation axis \(l_{r}\) is a straight line that passes through the origin \(O_{s}\). \(l_{r}\) can be described, using two parameters, by the symmetric equation of the line in space:  
\[l_{r}:\frac{x}{\sin\theta_{r}\cos\varphi_{r}}=\frac{y}{\sin\theta_{r}\sin \varphi_{r}}=\frac{z}{\cos\theta_{r}}, \tag{3}\]  
where \(\theta_{r}\) and \(\varphi_{r}\) are the polar and azimuthal angles of the line as shown in Figure 4a. The optical surface is a plane that passes through the origin \(O_{s}\). Let \(S_{g}(t)\) be the plane equation of the surface at scanning time \(t\). At the initial time (\(t=0\)), the surface is horizontal, meaning that the normal vector of \(S_{g}(0)\) is \(\mathbf{n}_{0}=(0,0,1)^{T}\). At any scanning time \(t\), the plane equation \(S_{g}(t)\) can be obtained by rotating \(S_{g}(0)\) counterclockwise about \(l_{r}\) by an angle of \(\omega t\) as  
\[S_{g}(t):n_{t}^{x}x+n_{t}^{y}y+n_{t}^{z}z=0\text{ with }\big{(}n_{t}^{x},n_{t}^{y}, n_{t}^{z}\big{)}^{T}=\mathbf{R}_{\omega t}\mathbf{n}_{0}, \tag{4}\]  
where \(\mathbf{R}_{\omega t}\) is the \(3\times 3\) rotation matrix corresponding to a rotation by an angle of \(\omega t\) about the fixed axis \(l_{r}\), which can be computed by [PERSON] rotation formula [21]. Since the illuminated spot is the intersection of the illumination light and the optical surface, it is required to parameterize the illumination light by a line. Let \(l_{i}(t)\) be the equation of the illumination line at scanning time \(t\):  
\[l_{i}(t):\frac{x-x_{i}}{\sin\theta_{i}\cos\varphi_{i}}=\frac{y-y_{i}-vt}{\sin \theta_{i}\sin\varphi_{i}}=\frac{z}{\cos\theta_{i}}. \tag{5}\]  
Four parameters are included in the equation, where \(\theta_{i}\) and \(\varphi_{i}\) are the polar and azimuthal angles of the illumination line, and \((x_{i},y_{i})\) is the coordinate of the initial illuminated spot. By solving the combined equation of Equations (4) and (5), one can obtain the coordinate of \(p(t)\) in the system coordinate system, denoted as \(\big{(}p_{s}^{x}(t),p_{s}^{y}(t),p_{s}^{z}(t)\big{)}\); this is subsequently transformed into the coordinate in the surface coordinate system by  
\[\left[ \begin{array}{c}p_{e}^{x}(t)\\ p_{e}^{y}(t)\end{array} \right]=\mathbf{R}^{{}^{\prime}}_{-\omega t}\!\!\left[ \begin{array}{c}p_{s}^{x}(t)\\ p_{s}^{y}(t)\\ p_{s}^{z}(t)\end{array} \right] \tag{6}\]  
Figure 4: Schematic of system state at different time during practical scanning. (**a**) Initial time (\(t=0\)); (**b**) Scanning time \(t\). where \(\mathbf{R}^{{}^{\prime}}_{-\omega t}\) is a \(2\times 3\) matrix consisting of the first two rows of the rotation matrix \(\mathbf{R}_{-\omega t}\). By substituting the surface coordinate of the illuminated spot, \(p_{e}^{x}(t),p_{e}^{y}(t)\), into Equation (2), one can finally obtain the mapping relationship from the sequence number \(n\) to the image coordinate \((u_{n},v_{n})\). For brevity, we use \(\mathbf{g}_{\boldsymbol{\psi}}\) to denote the mapping relationship, and therefore, the mapping function can be written as  
\[(u_{n},v_{n})^{T}\equiv\mathbf{u}_{n}=\mathbf{g}_{\boldsymbol{\psi}}(n), \tag{7}\]  
where \(\boldsymbol{\psi}=(\theta_{r},\varphi_{r},\theta_{i},\varphi_{i},x_{i},y_{i}, v,\omega,f)\) is the union of all parameters involved in the modeling, called the system parameter vector, which determines the mapping relationship \(\mathbf{g}_{\boldsymbol{\psi}}\). In the practical implementation, the mapping function, Equation (7), is calculated by the following 7 steps:  
1. Calculate the corresponding scanning time of the sequence number, as \(t=n/f\);
2.