我已经能够在python中使用lewiner行进立方体算法。它输出顶点、面和其他属性。我想要确保它工作正常,所以我想要绘制函数返回的3D图像。然而,到目前为止,我还没有取得任何成功。我尝试了以下几点:
成功检索必要的领域:
verts, faces, normals, values = skimage.measure.marching_cubes_lewiner(var,20,spacing=(0.5,0.5,0.5))以及检索到的值的不成功图幅:
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(projection='3d')
mesh = Poly3DCollection(verts[faces])
mesh.set_edgecolor('k')
ax.add_collection3d(mesh)还包括:
vv.mesh(np.fliplr(verts), faces, normals, values) # doctest: +SKIP假设情况下,我想在机器学习算法中使用verts、faces等,但我希望确保返回的值是可靠的。有人有过这样的经验吗?
发布于 2020-05-13 00:47:42
我不知道你是否还在寻找答案,但我只是遇到了一个问题,通过这个函数绘制网格。我没有犯什么错误,只有一个空的阴谋。如果您也是这样的话,我通过指定轴限值来解决这个问题。以下是我的诀窍:
import matplotlib.pyplot as plt
import numpy as np
from skimage.measure import marching_cubes_lewiner
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
# mask is a currently stored binary 3D numpy array
verts, faces, normals, values = marching_cubes_lewiner(mask)
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection="3d")
ax.set_xlim(np.min(verts[:,0]), np.max(verts[:,0]))
ax.set_ylim(np.min(verts[:,1]), np.max(verts[:,1]))
ax.set_zlim(np.min(verts[:,2]), np.max(verts[:,2]))
mesh = Poly3DCollection(verts[faces])
mesh.set_edgecolor('k')
ax.add_collection3d(mesh)
plt.tight_layout()
plt.show()https://stackoverflow.com/questions/60324627
复制相似问题