## 2 Reconstruction Principle
### Analytic Reconstruction Principle  
As we mentioned above, the main problem is that conducting an analysis according to the gray scale of image requires the information of the topographical gradient. Furthermore, the gray scale mainly depends on the inclination angle of surface patches. Thus, we propose a reconstruction analytic method to obtain the surface gradient, as shown in Figure 2.  
It was supposed that the vector of the light source was \(L(0,0,1)\), which takes the lens center as the coordinates of the origin. Furthermore, the \(z\)-axis of the coordinate system coincides with the optical axis of the imaging system, and the \(x\) and \(y\) axes are parallel to the imaging plane.  
Figure 1: Shape from shading (SFS) model.  
During the process of imaging, the surface topography is projected onto the image plane, and the surface topography data are converted to the gray scale data. The gray surface, which can be used to describe the gray scale distribution of an image, is converted into the object surface. A flatter object surface has a greater gray scale. \(A_{i}\) is a point on the image plane. \(A_{g}\) is the corresponding point on the gray surface with a normal vector of \(\textbf{{N}}_{g}(-p_{g},\,-q_{g},\,1)\) and inclination angle of \(\theta_{g}\). \(A_{w}\) is the corresponding point on the object surface with a normal vector of \(\textbf{{N}}\left(-p,\,-q,\,1\right)\) and inclination angle of \(\theta_{w}\). \(\varphi\) denotes the declination angle of points.  
Based on the analytic geometry theory [32], the declination angle of \(A_{g}\) is equal to that of \(A_{w}\), both of which are \(\varphi\). Therefore, the gradient relationship between the object surface and gray surface can be expressed as follows:  
\[\frac{p}{q}=\frac{p_{g}}{q_{g}}=tg\varphi \tag{4}\]  
Hence, the object surface gradient can be defined as:  
\[\left\{\begin{array}{l}p=kp_{g}\\ q=kq_{g}\end{array}\right. \tag{5}\]  
where \(k\) is the gradient scale coefficient. We found that the solution of the SFS algorithm will evolve into a regularization problem by using the gray gradient as the constraint condition.  
The gray gradient (\(p_{g},\,q_{g}\)) is given by the gray scale of image \(E(x,\,y)\):  
\[\left\{\begin{array}{l}p_{g}=E(x,y)_{x}\\ q_{g}=E(x,y)_{y}\end{array}\right. \tag{6}\]  
where \(E(x,\,y)_{x}\) and \(E(x,\,y)_{y}\) represent the gradient of gray scale \(E(x,\,y)\) in the \(x\) and \(y\) directions, respectively.  
Therefore, the object surface gradient can be written as follows:  
\[\left\{\begin{array}{l}p=kE(x,y)_{x}\\ q=kE(x,y)_{y}\end{array}\right. \tag{7}\]  
Figure 2: Analytic reconstruction principle.  
Furthermore, the vector of the light source \(\mathbf{L}(0,0,1)\) indicates that \(p_{0}\) and \(q_{0}\) are both. By substituting Equation (7) into Equation (3), we obtain an updated formula:  
\[E(x,y)=\frac{l_{0}\rho}{\sqrt{1+k^{2}[E(x,y)_{x}^{2}+E(x,y)_{y}^{2}]}} \tag{8}\]  
Hence, the gradient scale coefficient is given as:  
\[k(x,y)=\pm\Bigg{(}\frac{\left(l_{0}\rho\right)^{2}-E(x,y)^{2}}{E(x,y)^{2}[E(x,y)_{x}^{2}+E(x,y)_{y}^{2}]}\Bigg{)}^{1/2} \tag{9}\]  
By substituting Equation (9) into Equation (7), the object surface gradient is expressed as follows:  
\[\left\{\begin{array}{l}p=\pm\Bigg{(}\frac{\left(l_{0}\rho\right)^{2}-E(x,y) ^{2}}{E(x,y)^{2}[E(x,y)_{x}^{2}+E(x,y)_{y}^{2}]}\Bigg{)}^{1/2}E(x,y)_{x}\\ q=\pm\Bigg{(}\frac{\left(l_{0}\rho\right)^{2}-E(x,y)^{2}}{E(x,y)^{2}[E(x,y)_{x }^{2}+E(x,y)_{y}^{2}]}\Bigg{)}^{1/2}E(x,y)_{y}\end{array}\right. \tag{10}\]  
Therefore, the surface gradient of each point can be obtained by Equation (10), and the relative height of surface topography can also be calculated by using the integral method.