## 5 3D Skeleton Correcting Algorithm  
A 3D model thinning algorithm should keep the extracted skeleton connected. However, we found that the modified algorithm [21] failed to preserve connectivity. Figure 7 shows an example about how the algorithm disconnects the skeleton. The voxel p1 is a non-tail voxel because it is 26-adjacent to six voxels: p2, p3, q1, q2, q3, and q4. It also satisfies the template d7-2 in class D and will thus be removed. The voxel p2 is a non-tail voxel because it is 26-adjacent to five voxels: p1, p3, q2, q3, and q4. It also satisfies the template a5 in class A. Therefore, it will also be removed. The p3 voxel is a non-tail voxel because it is 26-adjacent to four voxels: p1, p2, q2, and q3. It also satisfies the template d9-3 in class D. Therefore, it will also be removed. When the voxels p1, p2, and p3 are removed, then the rest of the voxels are disconnected.  
Figure 6: Example of thinning the voxels of a pyramid structure by the partial parallel thinning algorithm. (**a**) A result after 10 iterations of thinning procedures; (**b**) A result after 20 iterations of thinning procedures.  
Figure 7: An example of disconnection.  
To preserve the connectivity of the skeleton, we propose a 3D skeleton correcting algorithm with six templates of inspecting the voxel disconnection. These templates are assigned to two classes: class E and class F. The templates in class E are shown in Figure 8. The black squares mean that at least one of them is 1. The templates in class E inspect the connectivity of the voxels by checking the distance between the voxels to determine whether it is greater than or equal to 2. After the target voxel p is removed, to satisfy the templates, the rest of the voxels are at the locations of both black squares and white squares. If the 26-adjacent voxels of the removed voxel satisfy the templates of class E, then the removed voxel p can be recovered. With the templates in class E, we can inspect whether voxels q1, q2, q3, and q4 in Figure 7 satisfy the template e3 after the last voxels of p1, p2, and p3 are removed. Thus, we can recover the last removed voxel to correct the disconnection of the skeleton and preserve connectivity.  
Another example of disconnection is shown in Figure 9. This case occurs after the target voxel is removed by template d11-1. Obviously, the remainder of the voxels are separated into two parts, which lead to the creation of a cavity. In this case, the removed voxel cannot be recovered by the templates in class E. Therefore, we propose the other three templates of class F to address such a special case.  
Figure 10 shows the templates in class F. The black triangles denote that at least one of them is 1. An additional criterion is employed to inspect the distances between the 26-adjacent voxels. We define the numbers of the voxels at the locations of white squares, black triangles and black squares as \(n_{ws}\), \(n_{bt}\), and \(n_{bs}\). The set of distances between the voxels at the locations of the white squares and those at the black triangles are defined as \(DW=\{dw_{1},dw_{2},\ldots,dw_{M}\},\ (M=n_{ws}\times n_{bt})\). The set of distances between the voxels at the locations of black squares and those at the black triangles are defined as \(DB=\{db_{1},db_{2},\ldots,db_{N}\},\ (N=n_{bt}\times n_{bs})\). The judgment of whether the target voxel will be recovered is defined as follows:  
\[rc=\left\{\begin{array}{l}false\text{,if}\min\{DW\}\leq\tau\ and\ \min\{DB\}\leq\tau\\ true\text{,}otherwise\end{array}\right. \tag{2}\]  
Figure 8: Correcting templates of class E.  
Figure 9: Another example of disconnection.  
The \(\tau\) is a threshold value for checking the 26-adjacent voxels and is equal to \(\sqrt{3}\). The target voxel will be recovered if the \(rc\) has a true value. Therefore, the removed voxel can be recovered based on any template in class F and the additional criterion.