将3d numpy数组转换为网格时出现“RuntimeError:在给定的iso值处找不到曲面”错误

2024-09-23 06:12:18 发布

您现在位置:Python中文网/ 问答频道 /正文

该程序将对给定的CT扫描进行分段。为此,我创建了一个深度学习模型。我在python中将CT扫描作为.nrrd文件读取,并将其转换为numpy数组,然后在此基础上训练我的模型。使用这个模型,我预测了一个正常工作的numpy阵列。当我尝试将此3d numpy数组转换为网格并最终转换为.stl格式时,就会出现问题

predImg = predictVolume(imgTarget)
vertices,faces,_,_ = marching_cubes_lewiner(predImg)

def dataToMesh(vert, faces):
mm = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
for i, f in enumerate(faces):
    for j in range(3):
        mm.vectors[i][j] = vert[f[j],:]
return mm


mm = dataToMesh(vertices, faces)
mm.save('tooth-segmented.stl')

Tags: 模型numpyfor数组mmdtypemeshct