-
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
Skeletonization issue with self-made mesh #13
Comments
Hi. It looks to me like your mesh is not fully connected - i.e. it consists of multiple disconnected shapes that only appear to be a closed surface. You can check this like so: >>> import networkx as nx
>>> cc = nx.connected_components(mesh.vertex_adjacency_graph)
>>> print(f'Mesh consists of {len(list(cc))} connected components')
Mesh consists of 70 connected components Without having seen what your Also another heads-up: I know it's somewhat counterintuitive but skeletonization of small primitives such as your cylinder often produce suboptimal results. You might be able to get better results by increasing the number of vertices (e.g. by subdividing). |
Thanks for the quick reply! I tried what you told me and it outputs me :
I am not sure I understand exactly what you said, but does this mean that almost nothing is connected in my mesh ? Otherwise, here are the inputs I gave :
|
A single connected component is actually what you want. Could you perhaps share the |
I am sorry ! here is the right one :
|
Ah OK. So here is the rub: Your set of faces + vertices is disconnected. If you set >>> mesh = trimesh.Trimesh(vertices=Matrixvertices,faces=triangle,process=False)
>>> cc = nx.connected_components(mesh.vertex_adjacency_graph)
>>> print(f'Mesh consists of {len(list(cc))} connected component(s)')
Mesh consists of 50 connected component(s) If you allow trimesh to fix it, things look better: >>> mesh = trimesh.Trimesh(vertices=Matrixvertices, faces=triangle, process=True)
>>> cc = nx.connected_components(mesh.vertex_adjacency_graph)
>>> print(f'Mesh consists of {len(list(cc))} connected component(s)')
Mesh consists of 1 connected component(s) Now going back to the skeletonization: I tried the wavefront skeletonization too but increased the number of waves. That helps if your mesh is very small and it therefore matters a lot where the wave starts. >>> skel = sk.skeletonize.by_wavefront(mesh, waves=10, step_size=1) It doesn't really look like what you would intuitively expect and the issue is that there are simply too few vertices to go by: I also checked if a mesh contraction would help but that looses the shape of the cylinder (red) and will hence lead to bad skeletons. >>> cont = sk.pre.contract(mesh) I'm not sure it's worth the effort since for a simple shape like this you can perfectly well just draw a skeleton yourself but if you want to try around some more, I would recommend increase the number of vertices and try to get them evenly distributed. |
Thanks a lot for the help ! Ok I just found out too that I have to let trimesh fix the duplicates, in order to be sure to have a closed mesh.
The fact is that I want to automate this because I have a set of meshes. So I need to get automatically this skeleton. Thanks again for the help! I will still try to increase the number of vertices to see if it works better. Have a nice week-end. |
Hi, I have a set of vertices and faces that I have given to Trimesh (my mesh is a perfect cylinder (all surface are closed)) .
But when I compute the skeletonization, it seems that something wrong has happened. The mesh isn't complete and so the skeletonization didn't work...
What did I do wrong ?
Here is my code for that part :
mesh = trimesh.Trimesh(vertices=Matrixvertices,faces=triangle,process=False)
trimesh.Scene(mesh).show()
fixed = sk.pre.fix_mesh(mesh, remove_disconnected=5, inplace=False)
skel = sk.skeletonize.by_wavefront(fixed, waves=1, step_size=1)
skel.mesh_map
skel.swc.head()
skel.show(mesh=True)
The text was updated successfully, but these errors were encountered: