I'm using mayavi.mlab
to plot cut planes through a volume in python.
The rendering is always interpolated. Is there a way to plot these planes without interpolation so that the pixels / voxels are visible?
Example code showing cut planes through a 20x20x20 voxel volume.
"""
Testing scalar_cut_plane
"""
import numpy as np
import mayavi.mlab as mlab
# creating volume that increases in value
img3d = np.arange(20)
img3d = np.expand_dims(img3d, axis=1)
img3d = np.expand_dims(img3d, axis=2)
img3d = np.tile(img3d, (1, 20, 20))
fig = mlab.figure()
src = mlab.pipeline.scalar_field(img3d)
# Plotting two cut planes
cp2 = mlab.pipeline.scalar_cut_plane(src, plane_orientation='y_axes')
cp2.implicit_plane.widget.enabled = False
cp3 = mlab.pipeline.scalar_cut_plane(src, plane_orientation='z_axes')
cp3.implicit_plane.widget.enabled = False
mlab.view(azimuth=50, elevation=None)
mlab.outline()
mlab.show()
Output
The best workaround that I could find to this problem was to use scipy interpolation to enlarge the volume without interpolation.
from scipy.ndimage.interpolation import zoom
img3d2 = zoom(img3d, 4, order=0)
The voxel size is now visible