Package: pc-skeletor
PC Skeletor - Point Cloud SkeletonizationPC Skeletoris a Python library for extracting a 1d skeleton from 3d point clouds usingLaplacian-Based ContractionandSemantic Laplacian-Based Contraction.AbstractStandard Laplacian-based contraction (LBC) is prone to mal-contraction in cases where
there is a significant disparity in diameter between trunk and branches. In such cases fine structures experience
an over-contraction and leading to a distortion of their topological characteristics. In addition, LBC shows a
topologically incorrect tree skeleton for trunk structures that have holes in the point cloud.In order to address
these topological artifacts, we introduce semantic Laplacian-based contraction (S-LBC). It integrates semantic
information of the point cloud into the contraction algorithm.Laplacian-Based Contraction (LBC)Semantic LBC (S-LBC)⚡️ Quick StartInstallationFirst installPythonVersion 3.7 or higher. The python package can be installed
viaPyPiusing pip.pipinstallpc-skeletorInstallation from Sourcegitclonehttps://github.com/meyerls/pc-skeletor.gitcdpc-skeletor
pipinstall--upgradepipsetuptools
pipinstall-rrequirements.txt
pipinstall-e.Basic UsageThe following code performs the skeletonization algorithm on a downloaded point cloud example. It also generates an
animation that includes the original point cloud and the resulting skeleton, which is exported as a gif.Download Example Datasetimportopen3daso3dimportnumpyasnpfrompc_skeletorimportDatasetdownloader=Dataset()trunk_pcd_path,branch_pcd_path=downloader.download_semantic_tree_dataset()pcd_trunk=o3d.io.read_point_cloud(trunk_pcd_path)pcd_branch=o3d.io.read_point_cloud(branch_pcd_path)pcd=pcd_trunk+pcd_branchLaplacian-Based Contraction (LBC)frompc_skeletorimportLBClbc=LBC(point_cloud=pcd,down_sample=0.008)lbc.extract_skeleton()lbc.extract_topology()lbc.visualize()lbc.show_graph(lbc.skeleton_graph)lbc.show_graph(lbc.topology_graph)lbc.save('./output')lbc.animate(init_rot=np.asarray([[1,0,0],[0,0,1],[0,1,0]]),steps=300,output='./output')Semantic Laplacian-Based Contraction (S-LBC)frompc_skeletorimportSLBCs_lbc=SLBC(point_cloud={'trunk':pcd_trunk,'branches':pcd_branch},semantic_weighting=30,down_sample=0.008,debug=True)s_lbc.extract_skeleton()s_lbc.extract_topology()s_lbc.visualize()s_lbc.show_graph(s_lbc.skeleton_graph)s_lbc.show_graph(s_lbc.topology_graph)s_lbc.save('./output')s_lbc.animate(init_rot=np.asarray([[1,0,0],[0,0,1],[0,1,0]]),steps=300,output='./output')OutputSkeletonTopologySkeletal GraphTopology Graphlbc.contracted_point_cloud:o3d.geometry.PointCloudlbc.skeleton:o3d.geometry.PointCloudlbc.skeleton_graph:networkx.nxlbc.topology:o3d.geometry.LineSetlbc.topology_graph:networkx.nxΩ ParametrizationLaplacian-Based ContractionLaplacian-Based Contraction is a method based on contraction of point clouds to extract curve skeletons by iteratively
contracting the point cloud. This method is robust to missing data and noise. Additionally no prior knowledge on the
topology of the object has to be made.The contraction is computed by iteratively solving the linear system\begin{bmatrix}
\mathbf{W_L} \mathbf{L}\\
\mathbf{W_H}
\end{bmatrix} \mathbf{P}^{'} =
\begin{bmatrix}
\mathbf{0}\\
\mathbf{W_H} \mathbf{P}
\end{bmatrix}obtained fromKin-Chung Au et al.$\mathbf{L}$ is the $n \times n$Laplacian Matrixwith cotangent weights. The Laplacian of a point cloud (Laplace-Beltrami Operator) can be used to compute themean
curvature Vector(p. 88 & p. 100). $\mathbf{P}$ is the original
point cloud, $\mathbf{P}^{'}$ a contracted point cloud and $\mathbf{W_L}$ and $\mathbf{W_H}$ are diagonal weight
matrices balancing the contraction and attraction forces. During the contraction the point clouds get thinner and
thinner until the solution converges. Afterwards the contracted point cloud aka. skeleton is sampled using
farthest-point method.To archive good contraction result and avoid over- and under-contraction it is necessary to initialize and update the
weights $\mathbf{W_L}$ and $\mathbf{W_H}$. Therefore the initial values and the maximum values for both diagonal
weighting matrices have to adjusted to archive good results.Semantic Laplacian-Based ContractionSemantic Laplacian-Based Contraction is based on Laplacian-based contraction and simply adds semantic knowledge to the
skeletonization algorithm.\begin{bmatrix}
\mathbf{S} \circ \mathbf{W_L} \mathbf{L}\\
\mathbf{W_H}
\end{bmatrix} \mathbf{P}^{'} =
\begin{bmatrix}
\mathbf{0}\\
\mathbf{W_H} \mathbf{P}
\end{bmatrix}Standard LBC is prone to mal-contraction in cases where there is a significant disparity in
diameter between trunk and branches. In such cases fine structures experience an over- contraction and leading to a
distortion of their topological characteristics. In order to address these topological artifacts, we introduce semantic
Laplacian-based contraction (S-LBC). For more information please refer to the [Paper].📖 Literature and Code used for implementationLaplacian based contractionOur implementation
ofPoint Cloud Skeletons via Laplacian-Based Contractionis a
python reimplementation of the originalMatlab code.Robust Laplacian for Point CloudsComputation of the discrete laplacian operator
viaNonmanifold Laplacecan be
found in therobust-laplacians-pyrepository.Minimum Spanning TreeThe Minimum Spanning Tree is computed viaMistreea
open-source implementation which can be foundhere.:interrobang: TroubleshootingFor Windows users, there might be issues installing themistreelibrary viapython -m pip install mistreecommand.
If you get an error message that the Fortran compiler cannot be found, please try the following:Download and install this suite of compilation tools:http://www.equation.com/servlet/equation.cmd?fa=fortranAdd thebinfolder in the installation directory to yourPATHenvironment variableAfter restarting your terminal and now trying to installmistreethis should work now.However, upon importing the library you might face an issue with missing DLL files. You simply need to copy or move
them within themistreeinstallation directory, as explained
here:https://github.com/knaidoo29/mistree/issues/14#issuecomment-1275022276Now the PC-Skeletor should be running on your Windows machine.:heavy_exclamation_mark: Limitation / ImprovementsImplementPoint2SkeletonImplementL1-Medial SkeletonTest codeImprove graph representation📖 CitationPlease cite this [Paper] if this work helps you with your research:@misc{meyer2023cherrypicker,
      title={CherryPicker: Semantic Skeletonization and Topological Reconstruction of Cherry Trees}, 
      author={Lukas Meyer and Andreas Gilson and Oliver Scholz and Marc Stamminger},
      year={2023},
      eprint={2304.04708},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}