All Projects → seung-lab → zmesh

seung-lab / zmesh

Licence: GPL-3.0 license
Marching Cubes & Mesh Simplification on multi-label 3D images.

Programming Languages

C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
cython
566 projects

Projects that are alternatives of or similar to zmesh

kimimaro
Skeletonize densely labeled 3D image segmentations with TEASAR.
Stars: ✭ 85 (+129.73%)
Mutual labels:  connectomics, biomedical-image-processing, volumetric-data
Meshlab
The open source mesh processing system
Stars: ✭ 2,619 (+6978.38%)
Mutual labels:  mesh-generation, mesh-processing, mesh-simplification
isosurface
Isosurface extraction using Marching Cubes and pure WebGL.
Stars: ✭ 66 (+78.38%)
Mutual labels:  marching-cubes-algorithm, marching-cubes
naive-surface-nets
Implements a simple, readable naive surface nets algorithm
Stars: ✭ 31 (-16.22%)
Mutual labels:  meshing, mesh-generation
Point2Mesh
Meshing Point Clouds with Predicted Intrinsic-Extrinsic Ratio Guidance (ECCV2020)
Stars: ✭ 61 (+64.86%)
Mutual labels:  mesh-generation, mesh-processing
MicroStructPy
Microstructure modeling, mesh generation, analysis, and visualization.
Stars: ✭ 42 (+13.51%)
Mutual labels:  meshing, mesh-generation
dmc
Dual Marching Cubes Implementation in C++
Stars: ✭ 45 (+21.62%)
Mutual labels:  mesh-generation, marching-cubes
PaiConvMesh
Official repository for the paper "Learning Local Neighboring Structure for Robust 3D Shape Representation"
Stars: ✭ 19 (-48.65%)
Mutual labels:  mesh-generation
VoxelTerrain
This project's main goal is to generate and visualize terrain built using voxels. It was achieved using different approaches and computing technologies just for the sake of performance and implementation comparison.
Stars: ✭ 37 (+0%)
Mutual labels:  marching-cubes
fpzip
Cython bindings for fpzip, a floating point image compression algorithm.
Stars: ✭ 24 (-35.14%)
Mutual labels:  connectomics
Triangulations
An implementation and presentation of selected mesh generation algorithms
Stars: ✭ 72 (+94.59%)
Mutual labels:  mesh-generation
SpatialSlur
Geometric data structures and algorithms for computational design tasks
Stars: ✭ 112 (+202.7%)
Mutual labels:  mesh-processing
loop subdivision
A C++ implementing of Loop subdivision
Stars: ✭ 19 (-48.65%)
Mutual labels:  meshing
Triangle.NET
C# / .NET version of Jonathan Shewchuk's Triangle mesh generator.
Stars: ✭ 276 (+645.95%)
Mutual labels:  mesh-generation
isosurface
Rust algorithms for isosurface extraction
Stars: ✭ 51 (+37.84%)
Mutual labels:  marching-cubes
intersection-wasm
Mesh-Mesh and Triangle-Triangle Intersection tests based on the algorithm by Tomas Akenine-Möller
Stars: ✭ 17 (-54.05%)
Mutual labels:  mesh-processing
mcut
A simple and fast library for mesh booleans and more.
Stars: ✭ 57 (+54.05%)
Mutual labels:  mesh-processing
Fast-Quadric-Mesh-Simplification-Pascal-
Mesh triangle reduction using quadrics (for Delphi, Lazarus and Pascal)
Stars: ✭ 46 (+24.32%)
Mutual labels:  mesh-simplification
lod-mesh
3D polygonal mesh renderer with dynamic level-of-detail (LOD).
Stars: ✭ 52 (+40.54%)
Mutual labels:  mesh-processing
jigsaw-python
Python bindings for JIGSAW: a Delaunay-based unstructured mesh generator.
Stars: ✭ 24 (-35.14%)
Mutual labels:  mesh-generation

zmesh: Multi-Label Marching Cubes & Mesh Simplification

Tests PyPI version

from zmesh import Mesher

labels = ... # some dense volumetric labeled image
mesher = Mesher( (4,4,40) ) # anisotropy of image

# initial marching cubes pass
# close controls whether meshes touching
# the image boundary are left open or closed
mesher.mesh(labels, close=False) 

meshes = []
for obj_id in mesher.ids():
  meshes.append(
    mesher.get_mesh(
      obj_id, 
      normals=False, # whether to calculate normals or not

      # tries to reduce triangles by this factor
      # 0 disables simplification
      simplification_factor=100, 

      # Max tolerable error in physical distance
      max_simplification_error=8,
      # whether meshes should be centered in the voxel
      # on (0,0,0) [False] or (0.5,0.5,0.5) [True]
      voxel_centered=False, 
    )
  )
  mesher.erase(obj_id) # delete high res mesh

mesher.clear() # clear memory retained by mesher

mesh = meshes[0]
mesh = mesher.simplify(
  mesh, 
  # same as simplification_factor in get_mesh
  reduction_factor=100, 
  # same as max_simplification_error in get_mesh
  max_error=40, 
  compute_normals=False, # whether to also compute face normals
) # apply simplifier to a pre-existing mesh

# compute normals without simplifying
mesh = mesher.compute_normals(mesh) 

mesh.vertices
mesh.faces 
mesh.normals
mesh.triangles() # compute triangles from vertices and faces

# Extremely common obj format
with open('iconic_doge.obj', 'wb') as f:
  f.write(mesh.to_obj())

# Common binary format
with open('iconic_doge.ply', 'wb') as f:
  f.write(mesh.to_ply())

# Neuroglancer Precomputed format
with open('10001001:0', 'wb') as f:
  f.write(mesh.to_precomputed())

Installation

If binaries are available for your system:

pip install zmesh

Requires a C++ compiler and boost

Note that you may need to set the environment variable BOOST_ROOT.

sudo apt-get install python3-dev libboost-all-dev
pip install zmesh --no-binary :all:

Performance Tuning & Notes

  • The mesher will consume about double memory in 64 bit mode if the size of the object exceeds <1023, 1023, 511> on the x, y, or z axes. This is due to a limitation of the 32-bit format.
  • The mesher is ambidextrous, it can handle C or Fortran order arrays.
  • The maximum vertex range supported .simplify after converting to voxel space is 220 (appx. 1M) due to the packed 64-bit vertex format.
  • There is a longstanding design flaw in cMesher.hpp that transposes the returned mesh and resolution. We're working on a backwards compatible solution. That's why you need to do mesher.mesh(data.T).

Related Projects

  • zi_lib - zmesh makes heavy use of Aleks' C++ library.
  • Igneous - Visualization of connectomics data using cloud computing.

Credits

Thanks to Aleks Zlateski for creating and sharing this beautiful mesher.

Later changes by Will Silversmith, Nico Kemnitz, and Jingpeng Wu.

References

  1. W. Lorensen and H. Cline. "Marching Cubes: A High Resolution 3D Surface Construction Algorithm". pp 163-169. Computer Graphics, Volume 21, Number 4, July 1987. (link)
  2. M. Garland and P. Heckbert. "Surface simplification using quadric error metrics". SIGGRAPH '97: Proceedings of the 24th annual conference on Computer graphics and interactive techniques. Pages 209–216. August 1997. doi: 10.1145/258734.258849 (link)
  3. H. Hoppe. "New Quadric Metric for Simplifying Meshes with Appearance Attributes". IEEE Visualization 1999 Conference. pp. 59-66. doi: 10.1109/VISUAL.1999.809869 (link)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].