skeletor icon indicating copy to clipboard operation
skeletor copied to clipboard

Cannot show the skeleton path

Open mikami520 opened this issue 2 years ago • 21 comments

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

mikami520 avatar Apr 01 '22 21:04 mikami520

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 avatar Apr 03 '22 19:04 schlegelp

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.

schlegelp avatar Apr 03 '22 19:04 schlegelp

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 avatar Apr 03 '22 19:04 mikami520

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.

mikami520 avatar Apr 03 '22 19:04 mikami520

Sorry, I think we're crossing wires here.

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

schlegelp avatar Apr 03 '22 19:04 schlegelp

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.

mikami520 avatar Apr 03 '22 19:04 mikami520

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

schlegelp avatar Apr 03 '22 19:04 schlegelp

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

mikami520 avatar Apr 03 '22 20:04 mikami520

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

Screenshot 2022-04-03 at 21 10 55

schlegelp avatar Apr 03 '22 20:04 schlegelp

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?

mikami520 avatar Apr 03 '22 20:04 mikami520

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.

schlegelp avatar Apr 03 '22 20:04 schlegelp

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?

mikami520 avatar Apr 03 '22 20:04 mikami520

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

Screenshot 2022-04-03 at 21 25 21

schlegelp avatar Apr 03 '22 20:04 schlegelp

Try git+https instead of git+git:

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

schlegelp avatar Apr 03 '22 20:04 schlegelp

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.

mikami520 avatar Apr 03 '22 20:04 mikami520

What version of trimesh and pyglet do you have?

schlegelp avatar Apr 03 '22 20:04 schlegelp

What version of trimesh and pyglet do you have?

pyglet==1.5.23
trimesh==3.10.7

mikami520 avatar Apr 03 '22 20:04 mikami520

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.

schlegelp avatar Apr 03 '22 20:04 schlegelp

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

mikami520 avatar Apr 03 '22 20:04 mikami520

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()

schlegelp avatar Apr 03 '22 20:04 schlegelp

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.

mikami520 avatar Apr 03 '22 20:04 mikami520