-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
too many "bones" in my skeleton? #48
Comments
Thanks for sharing! I take it the screenshot is showing the content of what your code saves as Assuming that's the case then you are saving the contracted mesh rather than the processed skeleton. The What you want to use are the Let me know if you need additional pointers (or if I have misinterpreted your code). |
On a side note: Your mesh will (correctly) result in a skeleton with cycles - which One work-around would be to use the vertex positions from the skeleton but the connectivity from the original mesh (a mapping between original vertices -> skeleton vertices is stored as |
Thank you for the reply. Yes, the screenshot is showing the content of what mycode saves as I cast a vote for adding cycle-breaking as an option. For my geometry, the skeletons I get from I am a bit confused about your suggesed work-around. In my code snippet, are you saying to use |
Sorry, I think we have crossed some wires here: Here is a quick example: >>> import skeletor as sk
>>> import trimesh as tm
>>> # Load the mesh
>>> m = tm.load('stent7.stl')
>>> # Fix potential issues with the mesh
>>> fixed = sk.pre.fix_mesh(m)
>>> # Contract the mesh
>>> # (this is entirely optional and can be finicky but seem to work well for your mesh)
>>> cont = sk.pre.contract(fixed)
>>> # Skeletonize the contracted mesh
>>> skel = sk.skeletonize.by_teasar(cont, inv_dist=1) The skeleton representation is stored as >>> skel.vertices
array([[ 0.92641366, 56.49105805, 24.53067979],
[ 0.95698625, 55.85853334, 24.18338986],
[ 0.86943069, 28.64119572, 24.39395668],
...,
[ 1.16120401, 73.83841077, 23.70497722],
[45.38167596, 27.16261274, 52.18504955],
[12.67703859, 57.79743991, 5.82538293]])
>>> skel.edges
array([[ 1, 0],
[ 2, 559],
[ 3, 398],
...,
[1369, 752],
[1370, 1154],
[1371, 870]]) Visualizing these vertices + edges gets us this: As you can see this now is a proper simplified, skeletal representation of your mesh. There is obviously room for improvement - I didn't bother trying different methods or adjusting parameters. The other thing you probably noticed in the screenshot is that the skeleton contains breaks while the mesh is obviously contiguous. That's the aforementioned cycle breaking that's currently baked into There are two potential ways of "mending" these breaks:
I had a quick crack at both these options and neither is trivial. Will have to look into it. |
I just added a new method to the If you re-install >>> # Starting from example above
>>> edges, vertices = skel.mend_breaks() There is a bit of a trade off as we introduce both true positive as well as false positive new edges but it doesn't look too bad. Some of remaining flaws like the bits sticking out (noise from the contraction) could be removed through further post-processing. |
Thank you for the clarification and for helping to fill the skeleton gaps! Any further enhancements to counter the intended cycle breaking would be welcome. For now, manually adding new bones to the skeleton seems like the way to go. |
The skeletons that I generate seem to have too many edges with overlaps and tiny branches, especially in proximity of intersections. Is there a method I should be using to reduce the skeleton to something more streamlined?
test.txt
stent7_stl.txt
The text was updated successfully, but these errors were encountered: