Skip to main content

Multilabel marching cubes and simplification of volumetric data.

Project description

zmesh: Multi-Label Marching Cubes & Mesh Simplification

Build Status PyPI version

from zmesh import Mesher

labels = ... # some dense volumetric labeled image
mesher = Mesher( (4,4,40) ) # anisotropy of image
mesher.mesh(labels) # initial marching cubes pass

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
    )
  )
  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

  • The mesher will consume about double memory in 64 bit mode if the size of the object exceeds <511, 1023, 511> on the x, y, or z axes. This is due to a limitation of the 32-bit format. It might be possible to get x to 1023 as well.
  • Input labels are converted to uint32 or uint64. Use one of these data types to avoid a copy.
  • The mesher processes in C order.

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-0.5.0.tar.gz (285.7 kB view details)

Uploaded Source

Built Distributions

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

zmesh-0.5.0-pp37-pypy37_pp73-manylinux2010_x86_64.whl (215.3 kB view details)

Uploaded PyPymanylinux: glibc 2.12+ x86-64

zmesh-0.5.0-pp36-pypy36_pp73-manylinux2010_x86_64.whl (215.3 kB view details)

Uploaded PyPymanylinux: glibc 2.12+ x86-64

zmesh-0.5.0-cp39-cp39-win_amd64.whl (200.3 kB view details)

Uploaded CPython 3.9Windows x86-64

zmesh-0.5.0-cp39-cp39-manylinux2010_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

zmesh-0.5.0-cp39-cp39-macosx_10_9_universal2.whl (371.4 kB view details)

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

zmesh-0.5.0-cp38-cp38-win_amd64.whl (200.7 kB view details)

Uploaded CPython 3.8Windows x86-64

zmesh-0.5.0-cp38-cp38-manylinux2010_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

zmesh-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl (245.0 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

zmesh-0.5.0-cp37-cp37m-win_amd64.whl (199.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

zmesh-0.5.0-cp37-cp37m-manylinux2010_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

zmesh-0.5.0-cp37-cp37m-manylinux1_x86_64.whl (924.4 kB view details)

Uploaded CPython 3.7m

zmesh-0.5.0-cp36-cp36m-win_amd64.whl (199.1 kB view details)

Uploaded CPython 3.6mWindows x86-64

zmesh-0.5.0-cp36-cp36m-manylinux2010_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

zmesh-0.5.0-cp36-cp36m-manylinux1_x86_64.whl (925.8 kB view details)

Uploaded CPython 3.6m

File details

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

File metadata

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

File hashes

Hashes for zmesh-0.5.0.tar.gz
Algorithm Hash digest
SHA256 605f2505a48b0746502438f6f05e7db931931ff8fbb996c3f8c9ae2e32e75131
MD5 20dc43eeb42375352aeb76be5a563f6e
BLAKE2b-256 b0728e3e74a7f8cb0e99542e13f9b6898c3c48537f18695b0c64ce74a9d2bc10

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-pp37-pypy37_pp73-manylinux2010_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-pp37-pypy37_pp73-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 215.3 kB
  • Tags: PyPy, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-pp37-pypy37_pp73-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 d2d8aaf5eee21f59d876923b8baee7cd1f06be5bdf31ad9254b91ca6bd38a82f
MD5 e6d3b8185882e44012f38997ff1eafc4
BLAKE2b-256 c7c045e72407e68e0d050b964effc50611d52f83c74c402dd7ae975520b5a291

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-pp36-pypy36_pp73-manylinux2010_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-pp36-pypy36_pp73-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 215.3 kB
  • Tags: PyPy, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 db688061dabfaff786d971e9f8d1d02431a67f11d0b692681236d7a46d2e8e8f
MD5 f93bbf2d33ca42cfbcd132c1ab5f13d5
BLAKE2b-256 dcb87481fd10719bf7fb29df323932bb962aea903d091ae3201c589330917b85

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zmesh-0.5.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 200.3 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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a904fc970234b456837a5fb9d455c9e2f53860ffec0b61c5bcac16502e7d002a
MD5 f8e7f3b311b3bae6b51566891c560f48
BLAKE2b-256 866862c5d8ebad1a7221eb6d5e71a76a26de3dfa336e7e0584e61d99776d3872

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9060e02870d048d6de6085b038797546e1937f16b1ed74b2c90559936a3140d8
MD5 09706aaaf9a2c65431b8cbfc02be809b
BLAKE2b-256 16520909cfdec50b2eddbb854c1a0637cfd3c24bff274e3fa2f29403fa157003

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zmesh-0.5.0-cp39-cp39-macosx_10_9_universal2.whl
  • Upload date:
  • Size: 371.4 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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 0d88e176b777ccd7fb6a41f8899e06b7ad4b922c1d0dd2d72bc158907ed62e19
MD5 d00f3411e56d114fe5a4b2828d810c1e
BLAKE2b-256 a7144c766b2b4084715a0be023bfaf32bb5bbf7737bb36e2dfc5d93f428adb7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zmesh-0.5.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 200.7 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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1d91216cfcc41514508bd04cd661224714736aa83fee05341e6b3f1f23390808
MD5 05d59bd2b5fca3e0b19142b714dc42e8
BLAKE2b-256 d75c7895416783c40303ea830688d95ddf682990e7c9f6b8d2aa4db81c6d10f3

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 bf4d14a742a382f7da9e22c9651cf8799f915a04551c5a839b4d3b10a691b36f
MD5 34114bc8d1794f3648f0fc09bf2d138e
BLAKE2b-256 01657e06c9be1eaf3f293af1425e2b2bc3e6489535a0cac4b0f77e6d3ee6edce

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 245.0 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7cacafe3dd53dd7defe9ff8e1869e2a50440fcdbda68cc6531ad42312e62a008
MD5 5e9aad10172d4b745d9cc7d97a12bf54
BLAKE2b-256 e5d13cb3915e04f7b3f1d1538c1a6a3a4490850daef52ca8fdeb9e6886d7240d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zmesh-0.5.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 199.0 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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 3a87f878549e2c7b79f5f8b7978c5c7d6b1d0f3f0f063097bd3c0281b931b63e
MD5 17d9016d29e4deb72a048138c35eeb74
BLAKE2b-256 e817863039c398ba457268e81d619bf645d72d0da282188c3bbf473a1ec236c4

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f6fac8f0cececa19596679cc3f78acdf4fd8360552a0f630fe6b313bbef2b749
MD5 17a73feef9a915e914317955c5a88027
BLAKE2b-256 940f04ecdf940071d5a74cb2112eabc277491fd56068a05079feb68ba89ee453

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 924.4 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f2a3ce954c679d40ffe008e6a4bc89b90b84dba6f4def95d1bc598edbf394694
MD5 199ea568b531be0054d0bd20cd7e493c
BLAKE2b-256 72b5bc260ccc438bc24fe56d67db7c420ffa74a31ea717daa6560a016ccef41b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: zmesh-0.5.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 199.1 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/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 010f082786699c97b9dacf2b99886d6b55b4d1633892bb4c9866df4e372d7466
MD5 e2abbbc374ba4a07371211868309a5cd
BLAKE2b-256 dc5e202638d312d806e510afdebe7c9fbe245004e90e36656204b41f7ee209ea

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ac74cd2cb42640cb36a2ab946e712da2a89087832535f01dbb50fcd94794969f
MD5 a2c16d55a71e5097313d52ef73e3b071
BLAKE2b-256 1e68aa2b6ac4824fe9680d1e5128b14dadb5c8004efca2932aee5d43ea9595d8

See more details on using hashes here.

File details

Details for the file zmesh-0.5.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: zmesh-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 925.8 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.8

File hashes

Hashes for zmesh-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 becf230b8adee38e1b044d89ff1f35a18aa601f1723450bffa5350d9e1d29e8c
MD5 f968097352985cc6f24048e568abf726
BLAKE2b-256 578a9dbacfce1e5d5c6a2527f770baaf11cad28b4c0abad44c3160d494571fe1

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