Skip to content
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

Cannot show the skeleton path #27

Open
mikami520 opened this issue Apr 1, 2022 · 21 comments
Open

Cannot show the skeleton path #27

mikami520 opened this issue Apr 1, 2022 · 21 comments

Comments

@mikami520
Copy link

Hi, I am working on the skeleton of 3D mesh. It is good to plot the skeleton path along with 3D mesh. However, if I want to only show the skeleton path, it displays nothing. Here is the screenshot of code and results. Hope someone can help me solve this issue. Also, I attached the mesh vtk file for you to reproduce.

Screen Shot 2022-04-01 at 17 43 50

pred_ETV2_178.vtk.zip

@schlegelp
Copy link
Collaborator

schlegelp commented Apr 3, 2022

Hi. You have me a bit confused. From your example, skel.show() should show just the skeleton and skel.show(mesh=True) should show both mesh and skeleton. Is that not what you're after?

skel.skeleton is a trimesh.path.Path3D which has its own .show() method which is independent of skeletor. Not sure why that's not working for you?

@schlegelp
Copy link
Collaborator

One addendum: the 3D plot (i.e. what you get from skel.show()) sometimes acts up for me and I have to drag/zoom first for stuff to pop up.

@mikami520
Copy link
Author

Hi. You have me a bit confused. From your example, skel.show() should show just the skeleton and skel.show(mesh=True) should show both mesh and skeleton. Is that not what you're after?

skel.skeleton is a trimesh.path.Path3D which has its own .show() method which is independent of skeletor. Not sure why that's not working for you?

@schlegelp Thanks for your response. I tried to use Path3D.show(), but I cannot see the path on the plot with zooming in or out.

@mikami520
Copy link
Author

import skeletor as sk
import pyvista as py
import trimesh.exchange.export
import numpy as np
pred = py.read('/Users/mikamixiao/Desktop/CIS 2/ET_data/registered/pred_329/pred_ETV2_178.vtk')
faces_as_array = pred.faces.reshape((pred.n_faces, 4))[:, 1:]
mesh = trimesh.Trimesh(pred.points, faces_as_array)
fixed = sk.pre.fix_mesh(mesh, remove_disconnected=5, inplace=False)
skel = sk.skeletonize.by_wavefront(fixed, waves=1, step_size=1)
skk = skel.skeleton 
print(type(skk))
skk.show()

Here is the code I am using now. It still gave blank plot.

@schlegelp
Copy link
Collaborator

Sorry, I think we're crossing wires here.

Why don't you use skel.show() (instead of skk.show)?

@mikami520
Copy link
Author

Sorry, I think we're crossing wires here.

Why don't you use skel.show() (instead of skk.show)?

I just want to see the skeleton path without the mesh, is there a way to do that? also, how to export this Path3D as stl or vtk? I tried to use trimesh.path.export, but it exported path3D as path2D.

@schlegelp
Copy link
Collaborator

skel.show() should just do that, i.e. show the skeleton without the mesh. Is it not doing that for you?

@mikami520
Copy link
Author

mikami520 commented Apr 3, 2022

skel.show() should just do that, i.e. show the skeleton without the mesh. Is it not doing that for you?

I did what you said, it is still blank plot. I tried to zoom in and out or rotate. Nothing showed there. I added the mesh to the previous commits, I am not sure if you can have a try on it to see if you also get the same results

@schlegelp
Copy link
Collaborator

Hmm. Works like a charm for me. Here's with skel.show(mesh=True):

Screenshot 2022-04-03 at 21 10 55

@mikami520
Copy link
Author

Hmm. Works like a charm for me. Here's with skel.show(mesh=True):

Screenshot 2022-04-03 at 21 10 55

That also works for me if I set mesh=True. Is there a way only to show the path (branches) instead of with mesh?

@schlegelp
Copy link
Collaborator

And it doesn't work if you do skel.show(mesh=False)? If that's the case, do me a favour and (re-)install skeletor from Github just to make sure you have the most recent version, and then try the whole thing again.

@mikami520
Copy link
Author

And it doesn't work if you do skel.show(mesh=False)? If that's the case, do me a favour and (re-)install skeletor from Github just to make sure you have the most recent version, and then try the whole thing again.

When I tried to re-install the skeletor from Github, it gives me some errors:

(proj_env) (base) mikamixiao@Mikamis-MacBook-Pro desktop % pip3 install git+git://github.com/navis-org/skeletor@master
Collecting git+git://github.com/navis-org/skeletor@master
  Cloning git://github.com/navis-org/skeletor (to revision master) to /private/var/folders/8c/dbj9256j58sc6fh7bjh4w_9c0000gn/T/pip-req-build-89mstobd
  Running command git clone --filter=blob:none --quiet git://github.com/navis-org/skeletor /private/var/folders/8c/dbj9256j58sc6fh7bjh4w_9c0000gn/T/pip-req-build-89mstobd
  fatal: remote error:
    The unauthenticated git protocol on port 9418 is no longer supported.
  Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
  error: subprocess-exited-with-error
  
  × git clone --filter=blob:none --quiet git://github.com/navis-org/skeletor /private/var/folders/8c/dbj9256j58sc6fh7bjh4w_9c0000gn/T/pip-req-build-89mstobd did not run successfully.
  │ exit code: 128
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet git://github.com/navis-org/skeletor /private/var/folders/8c/dbj9256j58sc6fh7bjh4w_9c0000gn/T/pip-req-build-89mstobd did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Do you have any idea about this error?

@schlegelp
Copy link
Collaborator

For reference, this is with skel.show(mesh=False);

Screenshot 2022-04-03 at 21 25 21

@schlegelp
Copy link
Collaborator

Try git+https instead of git+git:

pip3 install git+https://github.com/navis-org/skeletor@master

@mikami520
Copy link
Author

mikami520 commented Apr 3, 2022

Try git+https instead of git+git:

pip3 install git+https://github.com/navis-org/skeletor@master

I installed successfully, but it still did not show only the branches on plot. By the way, I used the Jupyter Notebook to plot the path.

@schlegelp
Copy link
Collaborator

What version of trimesh and pyglet do you have?

@mikami520
Copy link
Author

What version of trimesh and pyglet do you have?

pyglet==1.5.23
trimesh==3.10.7

@schlegelp
Copy link
Collaborator

schlegelp commented Apr 3, 2022

Same for me. Try running this please:

import trimesh as tm
import numpy as np
sc = tm.Scene(skel.skeleton.copy())
fac = 5 / np.fabs(skel.skeleton.bounds).max()
sc.apply_transform(np.diag([fac, fac, fac, 1]))
sc.show()

If that doesn't work either, I am fresh out of ideas.

@mikami520
Copy link
Author

mikami520 commented Apr 3, 2022

@schlegelp
I am sorry, it is still not gonna work. I also have no idea about this issue.

@schlegelp
Copy link
Collaborator

At the end of the day this is trimesh issue. I would suggest you open an issue in their repo. You could share this minimal example of plotting a single line:

import trimesh as tm
import numpy as np
vertices = np.array([[0, 0, 0], [1,1,1]])
lines = [tm.path.entities.Line([0, 1])]
p = tm.path.Path3D(entities=lines, vertices=vertices, process=False)
sc = tm.Scene(p)
sc.show()

@mikami520
Copy link
Author

At the end of the day this is trimesh issue. I would suggest you open an issue in their repo. You could share this minimal example of plotting a single line:

import trimesh as tm
import numpy as np
vertices = np.array([[0, 0, 0], [1,1,1]])
lines = [tm.path.entities.Line([0, 1])]
p = tm.path.Path3D(entities=lines, vertices=vertices, process=False)
sc = tm.Scene(p)
sc.show()

Thanks for your help! I will create an issue later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants