Marching Cubes

Use vectorized marching cubes algorithm to compute triangulated mesh of an isosurface from 3D matrix
7.9K Downloads
Updated 23 Jul 2013

View License

This function uses a vectorized version of the marching cubes algorithm to compute a triangulated mesh of the isosurface within a given 3D matrix of scalar values at a given isosurface value. The output is a triangulated mesh specified in terms of a face list and a vertex list. The orientation of the triangles is chosen such that the normals point from the higher values to the lower values. Optional arguments COLORS ans COLS can be used to produce interpolated mesh face colors.

This function was used to create a surface mesh from the CT scan dataset for the Stanford bunny, a 461 x 339 x 330 array of floats. See uploaded image. Elapsed time on an AMD Opteron 64-bit computer with 4 GB of RAM is 24.7 seconds. For comparison, a surface mesh was computed from the same dataset using Matlab's isosurface function, and the elapsed time was 98.6 seconds.

This function was adapted for Matlab by Peter Hammer in 2011 by making minor syntax changes to an Octave function written by Martin Helm <martin@mhelm.de> in 2009 (http://www.mhelm.de/octave/m/marching_cube.m)

Revised 30 September, 2011 to add code by Oliver Woodford for removing
duplicate vertices.

Cite As

Peter Hammer (2024). Marching Cubes (https://www.mathworks.com/matlabcentral/fileexchange/32506-marching-cubes), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: BiofilmQ, resolution truncated with 10 digit'

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.3.0.0

Changed description to include benchmarking results, and changed help section of mfile to more explicitly describe input arguments.

1.2.0.0

Revised 30 September, 2011 to add code by Oliver Woodford for removing duplicate vertices.

1.1.0.0

Added image of Stanford bunny meshed using this function. Added text describing this example to description.

1.0.0.0