3dvedo

how to convert a mesh to a volume


I have a mesh object which defines a 3D object and I can load it with vedo as:

from vedo import *
mesh = Mesh("myphantom.obj")
mesh.show()

What would like to do is convert this to a 3D volume which I can reslice. Is it possible to do this with vedo. I did not see any API call to do this.

in my case, basically I want to save all visible elements as a 3D label map i.e. a binary volume/segmentation.


Solution

  • You can try the following:

    from vedo import *
    mesh = Mesh(dataurl + "apple.ply")
    vol = mesh.binarize(spacing=(0.02,0.02,0.02))
    print(vol)
    vslice = vol.slice_plane(origin=(0,0,0), normal=(1,1,1)).cmap('jet')
    # print(vslice.pointdata["ImageScalars"])
    show(mesh, vol, vslice, N=3, axes=1)
    

    image output