Search code examples
pythonnumpymayavimarching-cubes

Smooth Mayavi Visualization of 3D Points


It's my first time visualizing in 3D and working with mayavi so please forgive my lack of knowledge. I have a 3D Numpy which I wanna visualize. The Array represents a voxel grid, so far I tried it with points3d, but the visualization doesn't look smooth, here is my code:

x, y, z = np.where(voxelGrid >= 100)
s = voxelGrid[voxelGrid >= 100]

z = z*2

mlab.points3d(x, y, z, s, scale_mode='none', color=(1,1,1), mode='sphere', scale_factor=3)
mlab.show()

Thats how it looks like: My Visualization

An Thats how I want it too look like: Expectation

What would be the best way to get it smooth like this? Thank you!!!

Edit: I have found out that I need a marching cube algorithm, how can I do that in python, is there anything in mayavi or vtk?


Solution

  • Hey Guys i found a way by using the library scikit-image, it has a very nice and fast function called measure.marching_cubes_lewiner()

    Marching Cube by scikit