I would like to plot 3D medical images using Python, Numpy and Matplotlib. I have been to trying to use the following snippet to display them but the image itself does not render.
import os
import imageio
import matplotlib.pyplot as plt, numpy as np
from mpl_toolkits.mplot3d import Axes3D
def make_ax(grid=False):
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ax.grid(grid)
return ax
x=os.listdir('Path to .dcm images')
print(x)
vol = imageio.volread('Path to .dcm images')
print(vol.shape)
ax = make_ax(True)
ax.voxels(vol, edgecolors='gray')
plt.show()
