diff --git a/doc/examples/edges/plot_marching_cubes.py b/doc/examples/edges/plot_marching_cubes.py index 5dad1680..919601b0 100644 --- a/doc/examples/edges/plot_marching_cubes.py +++ b/doc/examples/edges/plot_marching_cubes.py @@ -33,10 +33,10 @@ ellip_double = np.concatenate((ellip_base[:-1, ...], ellip_base[2:, ...]), axis=0) # Use marching cubes to obtain the surface mesh of these ellipsoids -verts, faces = measure.marching_cubes(ellip_double, 0) +verts, faces, normals, values = measure.marching_cubes(ellip_double, 0) # Display resulting triangular mesh using Matplotlib. This can also be done -# with mayavi (see skimage.measure.marching_cubes docstring). +# with mayavi or visvis (see skimage.measure.marching_cubes docstring). fig = plt.figure(figsize=(10, 12)) ax = fig.add_subplot(111, projection='3d') diff --git a/skimage/measure/_marching_cubes_classic.py b/skimage/measure/_marching_cubes_classic.py index 2cd936a2..da688204 100644 --- a/skimage/measure/_marching_cubes_classic.py +++ b/skimage/measure/_marching_cubes_classic.py @@ -86,24 +86,6 @@ def marching_cubes_classic(volume, level=None, spacing=(1., 1., 1.), To quantify the area of an isosurface generated by this algorithm, pass outputs directly into `skimage.measure.mesh_surface_area`. - Regarding visualization of algorithm output, to contour a volume - named `myvolume` about the level 0.0, using the ``mayavi`` package:: - - >>> from mayavi import mlab # doctest: +SKIP - >>> verts, faces = marching_cubes_classic(myvolume, 0.0) # doctest: +SKIP - >>> mlab.triangular_mesh([vert[0] for vert in verts], - ... [vert[1] for vert in verts], - ... [vert[2] for vert in verts], - ... faces) # doctest: +SKIP - >>> mlab.show() # doctest: +SKIP - - Similarly using the ``visvis`` package:: - - >>> import visvis as vv # doctest: +SKIP - >>> verts, faces = marching_cubes_classic(myvolume, 0.0) # doctest: +SKIP - >>> vv.mesh(np.fliplr(verts), faces) # doctest: +SKIP - >>> vv.use().Run() # doctest: +SKIP - References ---------- .. [1] Lorensen, William and Harvey E. Cline. Marching Cubes: A High diff --git a/skimage/measure/_marching_cubes_lewiner.py b/skimage/measure/_marching_cubes_lewiner.py index 66764ebc..d2ba4aa5 100644 --- a/skimage/measure/_marching_cubes_lewiner.py +++ b/skimage/measure/_marching_cubes_lewiner.py @@ -113,6 +113,27 @@ def marching_cubes(volume, level=None, spacing=(1., 1., 1.), keeping the algorithm relatively easy. This implementation is written in Cython, ported from Lewiner's C++ implementation. + To quantify the area of an isosurface generated by this algorithm, pass + verts and faces to `skimage.measure.mesh_surface_area`. + + Regarding visualization of algorithm output, to contour a volume + named `myvolume` about the level 0.0, using the ``mayavi`` package:: + + >>> from mayavi import mlab # doctest: +SKIP + >>> verts, faces, normals, values = marching_cubes(myvolume, 0.0) # doctest: +SKIP + >>> mlab.triangular_mesh([vert[0] for vert in verts], + ... [vert[1] for vert in verts], + ... [vert[2] for vert in verts], + ... faces) # doctest: +SKIP + >>> mlab.show() # doctest: +SKIP + + Similarly using the ``visvis`` package:: + + >>> import visvis as vv # doctest: +SKIP + >>> verts, faces, normals, values = marching_cubes_classic(myvolume, 0.0) # doctest: +SKIP + >>> vv.mesh(np.fliplr(verts), faces, normals, values) # doctest: +SKIP + >>> vv.use().Run() # doctest: +SKIP + References ---------- .. [1] Thomas Lewiner, Helio Lopes, Antonio Wilson Vieira and Geovan