# Motion-Induced Phase Error Compensation Using Three-Stream Neural Networks
## 2 Principle  
### Motion-Induced Error in Three-Step Phase-Shifting Algorithm  
The intensity distribution of \(N\)-step phase algorithm can be expressed as:  
\[I_{n}(x,y)=A(x,y)+B(x,y)\cos[\phi(x,y)-\delta_{n}(x,y)], \tag{1}\]  
\[\delta_{n}(x,y)=2\pi(n-1)/N,n=1,2,\ldots,N. \tag{2}\]  
where \(x\), \(y\) donates the pixel coordinate, \(A\), \(B\), \(\phi\) represents the background intensity, intensity modulation, and phase map, respectively. \(\delta_{n}\) is the theoretical phase shift, and \(n\) is the phase shift number. The desired phase map can be calculated by least square algorithm:\[\phi(x,y)=\arctan\frac{M(x,y)}{D(x,y)}=\arctan\frac{\sum\limits_{n=1}^{N}I_{n}(x,y) \sin\delta_{n}(x,y)}{\sum\limits_{n=1}^{N}I_{n}(x,y)\cos\delta_{n}(x,y)}. \tag{3}\]  
where \(M(x,y)\) and \(D(x,y)\) represent the numerator and denominator of the arctangent function, respectively. When the measured object is moving, the actual phase shift \(\delta_{n}^{\prime}\) becomes:  
\[\delta_{n}^{\prime}(x,y)=\delta_{n}(x,y)+\varepsilon_{n}(x,y). \tag{4}\]  
where \(\varepsilon_{n}(x,y)\) is the additional unknown phase shift caused by motion in \(n\)th fringe pattern. Similarly, the actual phase map \(\phi^{\prime}\) can be calculated by:  
\[\phi^{\prime}(x,y)=\arctan\frac{\sum\limits_{n=1}^{N}I_{n}(x,y)\sin\delta_{n} ^{\prime}(x,y)}{\sum\limits_{n=1}^{N}I_{n}(x,y)\cos\delta_{n}^{\prime}(x,y)}. \tag{5}\]  
Therefore, the motion-induced error can be expressed as [25]:  
\[\Delta\phi=\phi^{\prime}-\phi \tag{6}\] \[=\arctan\frac{\cos 2\phi\cdot\sum\limits_{n=1}^{N}\sin(2\delta_{n }+\varepsilon_{n})-\sin 2\phi\cdot\sum\limits_{n=1}^{N}\cos(2\delta_{n}+ \varepsilon_{n})-\sum\limits_{n=1}^{N}\text{sine}_{n}}{\cos 2\phi\cdot\sum \limits_{n=1}^{N}\cos(2\delta_{n}+\varepsilon_{n})+\sum\limits_{n=1}^{N}\text {cos}\varepsilon_{n}}.\]  
Equation (6) shows that the distribution of motion-induced error is related to the doubled frequency of the projected fringe. In this paper, three-step PSP is selected for analysis and measurement, since it requires minimum number of patterns with ensured accuracy. Three-step fringe patterns distorted by motion can be represent as:  
\[\begin{split} I_{1}(x,y)&=A(x,y)+B(x,y)\cos[\phi(x,y)-\varepsilon_{1}],\\ I_{2}(x,y)&=A(x,y)+B(x,y)\cos[\phi(x,y)-(2\pi/3+ \varepsilon_{1}+\varepsilon_{2})],\\ I_{3}(x,y)&=A(x,y)+B(x,y)\cos[\phi(x,y)-(4\pi/3+ \varepsilon_{1}+\varepsilon_{2}+\varepsilon_{3})].\end{split} \tag{7}\]  
where \(\varepsilon_{1}=0\). Considering a small phase shift error \(\varepsilon\), \(\sin(\varepsilon)\approx\varepsilon\), \(\cos(\varepsilon)\approx 1\), the actual phase of three-step PSP can be derived from Equation (5):  
\[\phi^{\prime}\approx\arctan\frac{\left(6+\sqrt{3}\varepsilon_{3}\right)\sin \phi-\left(6\varepsilon_{2}+3\varepsilon_{3}\right)\cos\phi}{\left(2 \varepsilon_{2}+\varepsilon_{3}\right)\sin\phi+\left(6-\sqrt{3}\varepsilon _{3}\right)\cos\phi}. \tag{8}\]  
The corresponding motion-induced error can be expressed as:  
\[\begin{split}\Delta\phi&\approx\arctan\frac{2\sqrt{3} \varepsilon_{3}\sin 2\phi-\left(4\varepsilon_{2}+2\varepsilon_{3}\right)\cos 2\phi- \left(8\varepsilon_{2}+4\varepsilon_{3}\right)}{-\left(4\varepsilon_{2}+2 \varepsilon_{3}\right)\sin 2\phi-2\sqrt{3}\varepsilon_{3}\cos 2\phi+12-2\sqrt{3} \varepsilon_{3}}\\ &\approx\frac{\sqrt{3}\varepsilon_{3}\sin 2\phi-\left(2\varepsilon_{ 2}+\varepsilon_{3}\right)\cos 2\phi}{6}-\frac{2\varepsilon_{2}+\varepsilon_{3}}{3}. \end{split} \tag{9}\]  
It can be seen that the phase error is periodically distributed and is a function of \(2\phi\). A spectral-filter-based or iteration-based method can be adopted to eliminate the motion-induced error. However, these methods usually decrease the ability of handling complex surfaces, or have prior assumptions on the movement forms, which limits their application in different types of objects.