marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
1.99k stars 260 forks source link

legosurface misses voxels #549

Open panangam opened 2 years ago

panangam commented 2 years ago

I'm using Volume and legosurface hoping to get a lego-style visualization of a voxel grid with only 0 and 1 values (drawing the voxels with value 1). I'm attaching a pic when I show the lego surface, and a pic when I just show the volume itself.

Screenshot from 2021-11-30 13-24-46

Screenshot from 2021-11-30 13-33-09

Clearly, the lego surface version is missing a LOT of voxels, even though the transparent visualization seems to show them. The voxels that are missing seem to be around where there is a 1-voxel-thick wall. Any idea what happened here?

(for lego surface I used vmin=0.5 and vmax=1.5 since I only want to show voxels with value 1.)

marcomusy commented 2 years ago

Hi, thanks for reporting.. that is a bit strange can you share some code and/or dataset?

panangam commented 2 years ago

Yep. Here's a json and the code to visualize it.

voxels.zip

import json
import vedo

with open('voxels.json') as fin:
    voxels = json.load(fin)
volume = vedo.Volume(voxels)
lego = volume.legosurface(vmin=0.5, vmax=1.5)
vedo.show(lego)

It's not exactly the same voxel grid as the one I showed above (I don't have that one anymore), but the effect is still visible.

marcomusy commented 2 years ago

Should now work: pip install -U git+https://github.com/marcomusy/vedo.git

lego = volume.legosurface(vmin=0.5, vmax=1.5, boundary=True)

Screenshot from 2021-12-01 20-26-54

panangam commented 2 years ago

Looks good, thanks! That was super quick. It seems like the colors are wrong though? The value is 1 so shouldn't it be orange?

Screenshot from 2021-12-01 11-37-32