navis-org / skeletor

Extraction of 3D skeletons from meshes.
https://navis-org.github.io/skeletor/
GNU General Public License v3.0
205 stars 25 forks source link

Thinning-based skeletonization #15

Open schlegelp opened 3 years ago

schlegelp commented 3 years ago

Look into implementing a thinning-based skeletonization. See e.g. this one based on skimage.

For this, we would need to first voxelize the mesh which is straight forward with Trimesh.

See also this function to extract a graph from pixel neighbourhood.

venugovh commented 2 years ago

Hi @schlegelp! I am trying to implement the skimagebased thinning algorithm for my research work. However, I am confused as to how to generate the mesh_map data that is available in skeletor. Since we generate the skeleton on the voxelized mesh of the input trimeshobject, I was wondering how mesh_map would work in this case.

Any input would be very helpful.

Thanks!

schlegelp commented 2 years ago

I guess it depends on your implementation but in general you would need to combine two maps:

  1. Vertex to voxel
  2. Voxel to pixel in the thinned image

The first one is straight forward, the second one is more tricky. AFAIK skimage's thinning won't give you a voxel -> pixel correspondence, so that would need to be calculated afterwards. You could just snap the vertices to the closest pixel using the Euclidean distance but that will give you wrong mappings in some cases. The correct approach would be to find the closest pixel using geodesic distance through the voxels graph but I have a feeling that this will be very expensive for larger meshes.