# A Layered Method Based on Depth of Focus for Rapid Generation of Computer-Generated Holograms
## 3 Performance  
The core problem of the polygon-based method is the diffraction of tilted triangles. In contrast, the proposed method approximates the diffraction calculation of tilted triangles to the diffraction calculation between parallel planes by projecting the triangles into layers according to the depth of focus, thus reducing the computational burden of the polygon-based method. To test the computational efficiency of the proposed method, the computational time consumption of the method is compared with that of the analytical polygon-based method [41] under the same conditions. The experiment was performed on a Windows 10 system, where algorithms were programmed in C++ within Visual Studio 2019 and then executed and displayed using MATLAB 2022. The computation time was measured using the \"tic\" and \"toc\" commands in MATLAB. The CPU version is the 11 th Gen Intel(R) Core (TM) i7-11800H. For accuracy and consistency, we limited the computation to a single thread. We created a 3D model  
Figure 6: The division of a three-dimensional object using parallel planes. using Blender and adjusted all models to have the same length along the z-axis. We set the hologram resolution to \(1024\times 1024\), the pixel spacing to 0.018 mm, the light wavelength to 532 nm, and the diffraction distance to 200 mm. The experimental results are shown in Table 3 and Figure 7. Table 3 shows the computational time consumption of the proposed method and the analytical polygon-based method, as well as the ratio of the time consumption of the analytical polygon-based method to that of the proposed method when computed on a CPU. Figure 7 shows the change in computation time with the number of triangles for both methods when computed on the CPU. The experimental results show that the computational speed of the proposed method is improved by about 20 times compared to the analytic polygon-based method, which confirms that it has a very high computational efficiency. The analytic polygon-based method, in order to calculate the diffraction of tilted triangles, requires a three-dimensional affine transformation of each triangle and the solution of complex analytic equations. Therefore, the computational time of this method is greatly affected by the number of triangles. Meanwhile, the proposed method avoids the direct computation of the diffraction of tilted triangles by approximating the triangle mesh as a set of planar light sources parallel to the holographic plane through the layered projection of the triangles according to the depth of focus. In the proposed method, the projection calculation of triangles does not involve complex calculations. It has a very low computational complexity, so the step can be accomplished in a very short time. In addition, the diffraction between the layer and the holographic plane can be quickly calculated using angular spectral diffraction with the support of the fast Fourier transformation. Therefore, the method has high computational efficiency. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**The Number of** & **The Proposed** & **The Analytical** & **Acceleration Ratio** \\
**Triangles** & **Method** & **Polygon-Based Method** & **Acceleration Ratio** \\ \hline
4704 & 10.7 s & 233.9 s & 21.9 \\
9408 & 22.2 s & 483.9 s & 21.8 \\
14,112 & 35.1 s & 709.4 s & 20.2 \\
18,816 & 48.5 s & 947.2 s & 19.5 \\
23,520 & 60.3 s & 1178.9 s & 19.6 \\
28,224 & 76.3 s & 1411.7 s & 18.5 \\
32,928 & 92.3 s & 1670.8 s & 18.1 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparison of time consumption between two methods on a CPU. Figure 7: The curve depicting the relationship between the time taken and the number of triangles for two methods on the CPU. Furthermore, we can observe that the computational time consumption of both methods is linearly related to the number of triangles.