Skip to content Skip to sidebar Skip to footer

Basic 3d Voxel Grid In Mayavi

I'm trying to visualize a 3D array through Mayavi in Python. I simply want to create a structured 3D voxel grid in which I can show some pre-specified voxel-space-filling points.

Solution 1:

Hi

import mayavi.mlab
import numpy

data = (100, 100, 100)
data = numpy.zeros(data)
data[0:50, 50:70, 0:50] = 1data[0:50, 0:20, 0:50] = 1

xx, yy, zz = numpy.where(data == 1)

mayavi.mlab.points3d(xx, yy, zz,
                     mode="cube",
                     color=(0, 1, 0),
                     scale_factor=1)

mayavi.mlab.show()

enter image description here

Post a Comment for "Basic 3d Voxel Grid In Mayavi"