我想使用 Python、Numpy 和 Matplotlib 绘制 3D 医学图像。我一直在尝试使用以下代码段来显示它们,但图像本身没有呈现。
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()
Helenr
相关分类