我一直在筛选 Mayavi 文档和 Google,但找不到任何有关 IsoSurface 类使用什么算法的说明。如果有帮助的话,我的源数据来自传递给 Mayavi.mlab.pipeline.scalar_field 函数的 3D NumPy 数组。以下是在包含 3D 立方体的图像上使用 iso_surface 函数的代码:
import numpy as np
from mayavi import mlab
img = np.pad(np.ones((5,5,5)), 1, mode='constant')
src = mlab.pipeline.scalar_field(img, figure=False)
iso = mlab.pipeline.iso_surface(src, contours=0.5)
iso_surface
函数生成 IsoSurface 的实例。 mayavi\modules\iso_surface.py 中的代码显示使用了 mayavi.components.contour。 mayavi\components\contour.py 中的注释表明它包装了 tvtk.ContourFilter。从本地安装中的 tvtk\tvtk_classes.zip\tvtk_classes\contour_filter.py 中找到的代码中,我在 ContourFilter
类的 __init__
方法中找到了这一点:
tvtk_base.TVTKBase.__init__(self, vtk.vtkContourFilter, obj, update, **traits)
查看源码code vtkContourFilter
以及 www.vtk.org 上的相关文档我没有看到对出版物的引用或其中实现的算法的名称。
最佳答案
正如您已经发现的,Mayavi 的 iso_surface
模块(最终)使用 VTK 的 vtkContourFilter
。 《可视化工具包:面向对象的 3D 图形方法,第 4 版》(Schroeder、Martin 和 Lorensen)一书中有几句话介绍了 vtkContourFilter
使用的算法。这是该书第 198 页的内容:
Contouring in VTK is implemented using variations of the marching cubes algorithm presented earlier. [...] For example, the tetrahedron cell type implements "marching tetrahedron" and creates triangle primitives, while the triangle cell type implements "marching triangles" and generates line segments.
还有一个 vtkMarchingCubes
过滤器,特定于图像数据(1d、2d 或 3d 网格上规则间隔的数据);本书继续比较 3d 体积的 vtkMarchingCubes
和 vtkContourFilter
之间的执行时间。
关于python - mayavi.mlab.pipeline.iso_surface.IsoSurface 使用什么算法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24852687/