skimage 0.17.2

NotesParametersReturnsBackRef
marching_cubes_classic(volume, level=None, spacing=(1.0, 1.0, 1.0), gradient_direction='descent')

Note that the marching_cubes() algorithm is recommended over this algorithm, because it's faster and produces better results.

Notes

The marching cubes algorithm is implemented as described in . A simple explanation is available here:

http://users.polytech.unice.fr/~lingrand/MarchingCubes/algo.html

There are several known ambiguous cases in the marching cubes algorithm. Using point labeling as in , Figure 4, as shown:

v8 ------ v7
 |       / |        y
 |      /  |        ^  z
----- v3   |        | /
v5 ----|- v6        |/          (note: NOT right handed!)
/      |  /          ----> x
       | /
----- v2

Most notably, if v4, v8, v2, and v6 are all >= :None:None:`level` (or any generalization of this case) two parallel planes are generated by this algorithm, separating v4 and v8 from v2 and v6. An equally valid interpretation would be a single connected thin surface enclosing all four points. This is the best known ambiguity, though there are others.

This algorithm does not attempt to resolve such ambiguities; it is a naive implementation of marching cubes as in , but may be a good beginning for work with more recent techniques (Dual Marching Cubes, Extended Marching Cubes, Cubic Marching Squares, etc.).

Because of interactions between neighboring cubes, the isosurface(s) generated by this algorithm are NOT guaranteed to be closed, particularly for complicated contours. Furthermore, this algorithm does not guarantee a single contour will be returned. Indeed, ALL isosurfaces which cross :None:None:`level` will be found, regardless of connectivity.

The output is a triangular mesh consisting of a set of unique vertices and connecting triangles. The order of these vertices and triangles in the output list is determined by the position of the smallest x,y,z (in lexicographical order) coordinate in the contour. This is a side-effect of how the input array is traversed, but can be relied upon.

The generated mesh guarantees coherent orientation as of version 0.12.

To quantify the area of an isosurface generated by this algorithm, pass outputs directly into skimage.measure.mesh_surface_area .

Parameters

volume : (M, N, P) array of doubles

Input data volume to find isosurfaces. Will be cast to :None:None:`np.float64`.

level : float

Contour value to search for isosurfaces in :None:None:`volume`. If not given or None, the average of the min and max of vol is used.

spacing : length-3 tuple of floats

Voxel spacing in spatial dimensions corresponding to numpy array indexing dimensions (M, N, P) as in :None:None:`volume`.

gradient_direction : string

Controls if the mesh was generated from an isosurface with gradient descent toward objects of interest (the default), or the opposite. The two options are: * descent : Object was greater than exterior * ascent : Exterior was greater than object

Returns

verts : (V, 3) array

Spatial coordinates for V unique mesh vertices. Coordinate order matches input :None:None:`volume` (M, N, P).

faces : (F, 3) array

Define triangular faces via referencing vertex indices from verts . This algorithm specifically outputs triangles, so each face has exactly three indices.

Classic marching cubes algorithm to find surfaces in 3d volumetric data.

See Also

skimage.measure.marching_cubes
skimage.measure.mesh_surface_area

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

skimage.measure._marching_cubes_classic.mesh_surface_area skimage.measure._marching_cubes_classic._correct_mesh_orientation

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /skimage/measure/_marching_cubes_classic.py#7
type: <class 'function'>
Commit: