Skip to main content

Multilabel marching cubes and simplification of volumetric data.

Reason this release was yanked:

Appearently defective simplification.

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zmesh-1.5.0.tar.gz (351.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zmesh-1.5.0-cp310-cp310-win_amd64.whl (246.9 kB view details)

Uploaded CPython 3.10Windows x86-64

zmesh-1.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

zmesh-1.5.0-cp310-cp310-macosx_10_9_universal2.whl (431.2 kB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

zmesh-1.5.0-cp39-cp39-win_amd64.whl (246.9 kB view details)

Uploaded CPython 3.9Windows x86-64

zmesh-1.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

zmesh-1.5.0-cp39-cp39-macosx_10_9_universal2.whl (431.2 kB view details)

Uploaded CPython 3.9macOS 10.9+ universal2 (ARM64, x86-64)

zmesh-1.5.0-cp38-cp38-win_amd64.whl (246.8 kB view details)

Uploaded CPython 3.8Windows x86-64

zmesh-1.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

zmesh-1.5.0-cp38-cp38-macosx_11_0_universal2.whl (424.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ universal2 (ARM64, x86-64)

zmesh-1.5.0-cp37-cp37m-win_amd64.whl (244.8 kB view details)

Uploaded CPython 3.7mWindows x86-64

zmesh-1.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

zmesh-1.5.0-cp36-cp36m-win_amd64.whl (244.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

zmesh-1.5.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

Details for the file zmesh-1.5.0.tar.gz.

File metadata

  • Download URL: zmesh-1.5.0.tar.gz
  • Upload date:
  • Size: 351.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0.tar.gz
Algorithm Hash digest
SHA256 8b67167d42e5cc47a4f30f6e8af6b4e9d936984b81976c0f5ac7a2ff7fce2079
MD5 53373ae58931a16537ef577ce80946f4
BLAKE2b-256 4405c494f48afcc4af005e438c368033d58e4cec9e37961f3d8b4f43ab680b08

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 246.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5378ac8faa8b0bddee01265e10ce932562b65fd12faeeab458c2fadb8b699ad6
MD5 fe71b9a1e2a52e80427e193f729f36d7
BLAKE2b-256 ca211ff862c345b569b269bba803a8c4396eb683971be9da9ea6f641d0ebf627

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zmesh-1.5.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b02ab42e55d279d55f44d9f4941c5a8144d55e0a34816faf65f3672ea301801b
MD5 90b0c348b2301b1d9845ae276ef8ec34
BLAKE2b-256 5e151226d45e05073f8d858fdb63141176b8bc7bf057d1779996d6b1846e87c3

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp310-cp310-macosx_10_9_universal2.whl
  • Upload date:
  • Size: 431.2 kB
  • Tags: CPython 3.10, macOS 10.9+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 4b2706052213d8680e413226f8c9c16dd2a98071bc029074637a79f518af1e0a
MD5 f3b045e611daf6e319316e01f40926b0
BLAKE2b-256 dc90ae930051015367141cf7d28bbd39e3bb6ef6c0f6e37b3fe3d0b3c8e482b4

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 246.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9893f22025f2ac41d2f1074f93ce19174ec7fd3d4ed08a6db5e564a36dbffc83
MD5 ccdaa9bcf14a535c9a724e971f344c18
BLAKE2b-256 2fa2e3a9efc4ea58a18de1fe4e2497d007917537cce85ec3ad4ce49b6929ce18

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zmesh-1.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a31dde68e760907b9a10a1910933434e35e66f1a473f30713662c7e521b9929
MD5 3b60fa0b200650102b05d706d3079723
BLAKE2b-256 b500aeb34d463d680b1788b1524353a3fb9ca9f01179a6f5bc9c9c57e5597377

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp39-cp39-macosx_10_9_universal2.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp39-cp39-macosx_10_9_universal2.whl
  • Upload date:
  • Size: 431.2 kB
  • Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 2c2304e76f3e6613a9b8ea3a64c6f107b177654f6b200c74b8f7accba4b57a86
MD5 d3c691f6cf15a0c522d402a330e2cb5e
BLAKE2b-256 5dbb7e87b8ccb5415f4c6781e4bcf0b76d55a9f7c6a85b302f2b40b230178615

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 246.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1331bd4b1f609eb5f196dfa306fd780fa70ac5ade325ea1ac7da2d4a4433a938
MD5 13dbaf850da0084cb2c34aa224b0679b
BLAKE2b-256 b28d486ad9051f63dfce17511d19cf7acaab41af65497fddb39394c98c6d0c23

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zmesh-1.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd274bd193adc79dca18c056f151fa2daa37ee85eac5c63090ede8d6750c60bb
MD5 6b1baa4fc5a27bdbaf66b01990b5f99c
BLAKE2b-256 b8a7aea2d1bf0e3ca734835414d8b9d9925e52ce0bd6cdd6220b2692b9f84e1c

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp38-cp38-macosx_11_0_universal2.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp38-cp38-macosx_11_0_universal2.whl
  • Upload date:
  • Size: 424.7 kB
  • Tags: CPython 3.8, macOS 11.0+ universal2 (ARM64, x86-64)
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp38-cp38-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 50bd1887808b7aacb6165340fa0c4af970be550f215831c7c64b48241e37edd1
MD5 81a40fc527fe175f4618944c31868fc0
BLAKE2b-256 6377a313156c739b521dde7b878276c6fa50c88ebe7b94f75e0e501f2ed9c90e

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 244.8 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 130fea226b6592cc2876810e21318f4ff9670ed69059bb27cab2cbe2ed3ad662
MD5 dc5096aa90a986b45c4952b5a8c1c4c9
BLAKE2b-256 51d06af02b8ac7aa3a32d2a70ef398a678408f952a551f7349153e805cdc2d42

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zmesh-1.5.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1b9453b69beaa9d11f7ee38d5f92609feb0f451e09944e7e6bc412e94c87845e
MD5 b8cbaa4990acd4d3457fb35b9319241b
BLAKE2b-256 c1fd8cc5d074fe766e59728db30e514c35209014a59fbccfcd8a141331236686

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: zmesh-1.5.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 244.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.10

File hashes

Hashes for zmesh-1.5.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 2135fbf5d2e1576572c862cd67e5780b842d43c2f2254940c2f30daca6f5ba23
MD5 312b0608f18fd5b9f7fc9a8d5afe51f4
BLAKE2b-256 4a3271166f1cb510f6ac40ebf8f74ab9797b552e789302826f2580fa1a6440c7

See more details on using hashes here.

File details

Details for the file zmesh-1.5.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for zmesh-1.5.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11fe4c49c9e33ce1ff4752a6cdb17daa07b6c85d6d54cf3894c9c5bb2873fa35
MD5 c41526c61e36cc7b9b644252d491e3fa
BLAKE2b-256 899cd1e53b89d3cd6944644293b6b8d94e1e92db6fb685c4f252dc3068002dfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page