# Stable Evaluation of 3D Zernike Moments for Surface Meshes
## 6 Numerical Results
### Accuracy of the Computed 3D Zernike Moments: Comparison with Other Algorithms  
In the specific case of a homogeneous shape, the version of the [PERSON]'s theorem for Zernike moments allows us to monitor the convergence of the computations of these moments. Indeed, for an 0 shape, \(f^{2}(x)\) is constant. Taking this constant to 1, we get  
\[\sum_{n=0}^{\infty}\sum_{l}\sum_{m=-l}^{l}|c_{nl}^{m}|^{2}=\int_{\mathbb{B}}f^ {2}\mathrm{d}x=\int_{V}\mathrm{d}x.\]  
In parallel, we have:  
\[c_{00}^{0}=\int_{\mathbb{B}}f^{2}(x)Z_{00}^{0}dx=\sqrt{\frac{3}{4\pi}}\int_{V} \mathrm{d}x.\]  
Therefore,  
\[\sum_{n=0}^{\infty}\sum_{l}\sum_{m=-l}^{l}|c_{nl}^{m}|^{2}=\sqrt{\frac{4\pi}{3 }}c_{00}^{0}. \tag{38}\]  
This implies that the Euclidean norm of the Zernike moments up to order N converges to a factor times \(\sqrt{c_{00}^{0}}\) when N increases, which can be used as a test for the numerical stability of the algorithm. Figure 5 shows this convergence for three different programs for computing the Zernike moments, for maximum order up to 150. All calculations are performed on a discretized sphere represented with a mesh of 20,480 triangles (this mesh was generated from the regular icosahedron with 5 consecutive subdivisions of its facet). This sphere is scaled inside the unit ball such that its maximum radius is \(r_{0}=0.75\). The computations were performed on one thread of a Linux server, with a Xeon Platinum 8168 CPU running at 2.7 GHz.  
The first program we use implements the computation of the Zernike moments from the geometric moments of the shapes, using the PK algorithm proposed by [PERSON] et al. [52], with the modified computation of geometric moments proposed by [PERSON] [53]. All calculations are performed in double precision. As seen in Figure 5, the convergence breaks down at \(N=50\); this is similar to the behavior described by [PERSON] et al. [52] for their own  
Figure 5: Numerical stability of the computation of Zernike moments. We plot the ratio of the sum of the norms of the Zernike moments to the value of \(c_{00}^{0}\); this ratio should converge to \(\sqrt{\frac{4\pi}{3}}\) (see Equation (38)). We use three different programs, PK-double that implements the PK algorithm which is a computation of the Zernike moments from the geometric moments of the shape using double precision 0, PK-GMP that implements the same calculation using full arbitrary precision arithmetic, and Shape2 Zernike based on Algorithm 3 of this study.  
algorithm, and for the alternate algorithm proposed by [PERSON] and [PERSON] [22]. We believe, in par with their comments, that the divergence is due both to the summations needed for computing the Zernike moments from the geometric moments that involve terms with alternating signs, and to the accuracy with which both high order monomials and high order binomial coefficients are computed.  
One option to circumvent this divergence problem is to increase the precision with which real numbers are represented. The second program we have used is a rewrite of the first program that makes full use of the GNU Multiple Precision (GMP) library. The calculations of the geometric moments involve linear recursions; they can therefore be performed using arbitrary precision integer arithmetics. The conversion to Zernike moments is then performed with floats with 512 bit accuracy. As seen in Figure 5, this full GMP implementation converges for order up to 100. It still fails, however, for order higher than 100. In addition, the computational cost however is high: the full GMP calculation required 4200 s for \(N=100\), while the double precision float calculation only requires 100 s.  
The third program with have used is Shape2 Zernike implementing Algorithm 3 introduced in this paper. Compared to the two other programs, it computes the Zernike moments directly, without relying on the geometric moments. It is found to be stable over a wide range of order (we have tested it up to order 400). It has a moderate computational cost (220 s).