# Extended Depth-of-Field of a Miniature Optical Endoscope Using Wavefront Coding
## 3 Design and Simulation
### Optical Endoscope with Phase Mask  
Wavefront coding is normally used to enhance the DOF of the optical endoscope by making the imaging the system insensitive to defocus aberrations. A wavefront coding optical element is a phase mask, placed at the plane of aperture stop, that introduces a spatially varying optical path length [17; 18]. The phase mask is ordinarily fabricated by exposure of a photoresist over-coated mask plate to an electron beam to form a specific pattern. The manufacture accuracy of mask plate height is approximately 1 nm. The equation for the surface of used phase mask can be written as  
\[f(x,y)=A[(\frac{x}{R})^{2}+(\frac{y}{R})^{2}]+B[(\frac{x}{R})^{3}+(\frac{y}{R} )^{3}]+C[(\frac{x}{R})^{5}+(\frac{y}{R})^{5}] \tag{11}\]  
where \(A\), \(B\) and \(C\) represent the structural parameters, and \(R\) stands for the radius of the phase mask. An effective way to optimize the structure of phase mask follows the principle that preserves consistency of MTFs with various defocus distances. Considering the multi-configuration method, the evaluation function can be given by  
\[MF^{2}=\sum_{i}\sum_{j}\sum_{k}[MTF(u_{i},\ v_{j},\ \varphi_{k})-MTF(u_{i},\ v_{j}, \ 0)]^{2} \tag{12}\]  
where \(MTF(u_{i},\ v_{j},\ \varphi_{k})\) represents the \(MTF\) with defocus value \(\varphi_{k}\) at different horizontal spatial frequency \(u_{i}\) and vertical spatial frequency \(v_{j}\), and \(MTF(u_{i},\ v_{j},\ 0)\) represents the \(MTF\) with different horizontal spatial frequency \(u_{i}\) and vertical spatial frequency \(v_{j}\) at the focal plane. After selecting 100 different defocus values \(\varphi_{k}\) between \(\varphi=0\) and maximum defocus value, each difference between \(MTF(u_{i},\ v_{j},\ \varphi_{k})\) and \(MTF(u_{i},\ v_{j},\ 0)\) is calculated and recorded. After the optimization by above criteria in Zemax, the parameters of \(R=0.418\) mm, \(A=-0.00579\), \(B=0.033274\) and \(C=0.13038\) are obtained. The structure of the proposed phase mask is depicted in Figure 5.  
Figure 4: Spot diagrams of initial optical endoscope, varied by different object distances and FOVs. Each column stands for the same object distance (e.g., 1.8 mm), and each line stands for the same FOV (e.g., 0\({}^{\circ}\)). The blue cross, green square and red triangle represent the 0.486 μm, 0.586 μm and 0.656 μm incident light. Under the manipulation of phase mask, the light ray, propagating between the optical lenses, has been modified from focusing state at a special point (Figure 6a) to defocusing state in a certain range (Figure 6b). The phase mask is constructed to avoid the presence of zeros in the corresponding MTF curves and calculus errors in the recovery procedure. Figure 7 exhibits the MTF curves calculated by Equation (9) in Matlab software, and the curves almost overlap when varying the objective distances. Most importantly, the zero points appearing in the initial system vanished with the help of the phase mask, which indicates all the spatial information is reserved in the wavefront coding system. The simulated results of MTF curves acquired by Zemax both in tangential and sagittal directions are shown in Figure 8a,b, respectively. All the curves stay invariant with objective distance ranging from 1.8 to 4.5 mm. The spot diagrams with wavefront coding technique in various objective distances and FOVs are described in Figure 9, which reflects a comprehensive view of how an image forms on the image sensor. We find that all the spots on the image sensor keep same style and size. The features of MTFs and spot diagrams in the new system bring a lot of benefits to acquiring and restoring the high-quality images with extended DOF. Figure 5: Structure of the proposed phase mask. (**a**) 2D map. (**b**) 3D map. Figure 6: Light ray propagated in the initial optical endoscope (**a**) and optical endoscope with phase mask (**b**). Figure 8: Simulated MTF curves of optical endoscope with phase mask, varied with object distances. (**a**) Tangential direction. (**b**) Sagittal direction.