# Stable Evaluation of 3D Zernike Moments for Surface Meshes
## 6 Numerical Results
### Accuracy of the Computed 3D Zernike Moments: Comparison with Exact Values  
In the previous section, we have looked at the stability of the algorithm. To assess its accuracy, we considered a sphere centered at the origin with radius \(r_{0}\) with \(0<r_{0}<1\). The Zernike moments of such a sphere are defined as  
\[c_{nl}^{m}=\sqrt{2n+3}\int_{0}^{r_{0}}\mathrm{d}r\,r^{2}R_{nl}(r)\int_{0}^{ \pi}\sin\theta\mathrm{d}\theta\int_{0}^{2\pi}\mathrm{d}\phi\overline{Y_{l}^{ m}(\theta,\phi)}.\]  
Let us recall first the orthonormality of the spherical harmonics:  
\[\int_{0}^{\pi}\sin\theta\mathrm{d}\theta\int_{0}^{2\pi}\mathrm{d}\phi\overline {Y_{l}^{m}(\theta,\phi)}\overline{Y_{l^{\prime}}^{m^{\prime}}(\theta,\phi)}= \delta_{mm^{\prime}}\delta_{ll^{\prime}}. \tag{39}\]  
Applying this equation for \(m^{\prime}=0\) and \(l^{\prime}=0\), and using the fact that \(Y_{0}^{0}=1/\sqrt{4\pi}\), we get  
\[\int_{0}^{\pi}\sin\theta\mathrm{d}\theta\int_{0}^{2\pi}\mathrm{d}\phi Y_{l}^{ m}(\theta,\phi)=\sqrt{4\pi}\delta_{m0}\delta_{l0}.\]  
The integral on the left is therefore non zero only for \(l=0\) and \(m=0\), in which case it is equal to \(\sqrt{4\pi}\). The Zernike moments \(c_{nl}^{m}\) of a sphere are then non zero only for \(l=0\) and \(m=0\):  
\[c_{n0}^{0}(ref)=\sqrt{4\pi}\sqrt{2n+3}\int_{0}^{r_{0}}r^{2}R_{n0}(r)dr=\sqrt{ 4\pi}\sqrt{2n+3}Q_{n0}(r_{0}), \tag{40}\]  
where \(Q_{n0}\) is defined in Equation (27). Note finally that, as \(l=0\) is even, \(n\) needs also to be even. The exact algorithm (Algorithm 2) and the finite precision algorithm (Algorithm 3, with TOL set to \(10^{-8}\)) have been applied to compute the Zernike moments of order 100 of triangle meshes representing the sphere with radius \(r_{0}=0.75\). Those meshes were constructed from successive subdivisions of the icosahedron, leading to eight meshes with 80 facets for the coarser, and 1,310,720 facets for the finer. The error has been measured using the Euclidean distance between the Zernike moments computed numerically with the exact or with the finite precision algorithm, and the reference Zernike moments computed from Equation (40), divided by the Euclidean modulus of the reference:  
\[E=\frac{\sqrt{\sum_{nlm}\left|c_{nl}^{m}-c_{nl}^{m}(ref)\right|^{2}}}{\sqrt{\sum _{nlm}\left|c_{nl}^{m}(ref)\right|^{2}}}.\]  
Results for the exact algorithms are shown in Figure 6. Those for the finite precision algorithm are 0. As expected, the error decreases as the number of triangles in the mesh decrease. The meshes we have used do not represent the sphere exactly; the representation improves, however, as the number of triangles increase. The errors observed in Figure 6 relate to this discretization error. The error associated with computing the Zernike polynomial are minimal compared to those. As discussed above, while it is possible to compute the Zernike moments for a sphere analytically, representation of a sphere with a discrete 3D mesh is only approximate. To further analyze the accuracy of our algorithms, we considered a second simple shape, a cube. Such a cube can be represented exactly with a triangular mesh: we considered a cube with 12 facets aligned with the 0 axes and just fitting in the unit ball (thus with edges of size \(2/\sqrt{3}\)). There are no analytical formula for the Zernike moments of a cube. However, they can be computed _symbolically_ using a symbolic algebra system (we have used Mathematica [63]). To achieve this, we generated the monomial expansion of the Zernike polynomials and then integrated them symbolically over the volume of the cube. This provided an exact symbolic result for each moment which was then evaluated to double precision.