Multilabel marching cubes and simplification of volumetric data.
Project description
zmesh: Multi-Label Marching Cubes & Mesh Simplification
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
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
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
- 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.
- TK Quadratic Edge Collapse Paper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zmesh-0.4.0.tar.gz.
File metadata
- Download URL: zmesh-0.4.0.tar.gz
- Upload date:
- Size: 282.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0aaab09818c7f4977ccadd555d66140916e278ccd805bb76f9422138b287ab9e
|
|
| MD5 |
2bd451ec6d4e71e9881d5f73b9750ee3
|
|
| BLAKE2b-256 |
bacc9b37ac7d6b186f55c8745be73ebc3394758009c1d8cd0cd9b801c7e6eb7a
|
File details
Details for the file zmesh-0.4.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 212.1 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90bb20292b0a8d5cfa9ce52b853d7a5ff187e2f30b58a7466e4e91d8969c9e9c
|
|
| MD5 |
d3a41350b9c22b605446d5386ebf3954
|
|
| BLAKE2b-256 |
15107561d141097c29cc813038f3a6617abc8687a391b4c43457397522ea570f
|
File details
Details for the file zmesh-0.4.0-cp39-cp39-macosx_10_9_universal2.whl.
File metadata
- Download URL: zmesh-0.4.0-cp39-cp39-macosx_10_9_universal2.whl
- Upload date:
- Size: 369.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed9e1098346d202585972f06e4763fa4e81aa03f2aba2e7496ace0bdd51175e4
|
|
| MD5 |
823312e0bceb6af26c21b7a1327ca8e8
|
|
| BLAKE2b-256 |
956953fca23b42ccddc6b0161d91810fb7766eb35cd247da2e714cb0f0e2724b
|
File details
Details for the file zmesh-0.4.0-cp38-cp38-manylinux1_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp38-cp38-manylinux1_x86_64.whl
- Upload date:
- Size: 920.3 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3c1dc7e52aa810b2b242f976a9364ad8d48255e94051e55995e4376d270284b
|
|
| MD5 |
bb069437605b6911fc1f035e960356b1
|
|
| BLAKE2b-256 |
355f565ee952a0fb937938dd616f69a27e56f8a9a5d43b8f98e8593925abe1fd
|
File details
Details for the file zmesh-0.4.0-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 228.6 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7740d95d6dd22ca5e7fba448047a08f651321cf109e853a8c4bfd77c5e4ce282
|
|
| MD5 |
5a4e6471af58138abe472b2c29c4ffbe
|
|
| BLAKE2b-256 |
c00c59033dfafce8cfb407198f61e60b62075b695c0861bf70814b407b66b19e
|
File details
Details for the file zmesh-0.4.0-cp38-cp38-macosx_10_9_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 247.9 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7f8a8eafca6c6e6c46edde12c2cbf5dbbf900c64731ae652623e81a3d750118
|
|
| MD5 |
2b21dc336915eca3864669dc270e3c90
|
|
| BLAKE2b-256 |
4d47ab582e2ca494a20718ad30196280e964f580cc2d92e351a2651899e1424b
|
File details
Details for the file zmesh-0.4.0-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 216.0 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77e50b1d2614b87cab3545a4b7f4124e3effc52c1840f600bb4834a71ec28a2d
|
|
| MD5 |
c864bf0fb1d4f690679e4535fc4b2e42
|
|
| BLAKE2b-256 |
3194c2732c63df989bfc88d108b5022d21e1f63ed6a779cb7c9f02cdb10b6952
|
File details
Details for the file zmesh-0.4.0-cp37-cp37m-manylinux1_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 917.0 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1bf233df358f5fa275bfbfaf7ba84d85e0dddc81bd32dd5287a27813dd3528c
|
|
| MD5 |
3687d8f2addd2be8f45a4b6a956da62d
|
|
| BLAKE2b-256 |
df92059a92fb4530e2304dabe96275bfd28fd78264429b93785ca424183ae639
|
File details
Details for the file zmesh-0.4.0-cp37-cp37m-macosx_10_9_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 245.8 kB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a37fedb0c679e8d8f71d301ed0dfb7e67ae2133f2c631a30b587b019d8b8e66a
|
|
| MD5 |
a483dd582ce20f3275c87fb516b181fc
|
|
| BLAKE2b-256 |
f3d0b5e15ed9f6f0fb928a829deded420897209ef578c15a59b69817611f65df
|
File details
Details for the file zmesh-0.4.0-cp36-cp36m-win_amd64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 216.1 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.5.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f0cedb9a525b4a00a0b5a66c5b38e86c39c4a563158a6c05720a2b8ddd6ff1a
|
|
| MD5 |
628787e4b398d9941a85aac9e8ea1664
|
|
| BLAKE2b-256 |
0b72b2d8403eec6b1d0ffe956dc6dddde7ff5b75788ffa020c387e773336664d
|
File details
Details for the file zmesh-0.4.0-cp36-cp36m-manylinux1_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 919.2 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9847965122fbbf8e29d7a77e4af95b5b4d6cfb259a29fe0befa7aeafa44eafd
|
|
| MD5 |
e6570f3063ad3b0c6038ebe07dc45588
|
|
| BLAKE2b-256 |
abc8fdd8372fcfaed2765265bcabc2d44c8b4fcfda87d0994b12f76245a65e5e
|
File details
Details for the file zmesh-0.4.0-cp36-cp36m-macosx_10_9_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp36-cp36m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 248.5 kB
- Tags: CPython 3.6m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b65c144d55eb47582991d1574ef22a4b632d5d89995dc70b96067a2a4215b95
|
|
| MD5 |
3fca0362a6f03aee70262b184f0a666a
|
|
| BLAKE2b-256 |
99debd7064983533157a326941db58a79849768a2d29521cc2b454a7d21cf51e
|
File details
Details for the file zmesh-0.4.0-cp35-cp35m-manylinux1_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 907.3 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
961624f7d1a3467af26722834c187ef80b5d759fa0aab4463ec710e2ff961771
|
|
| MD5 |
2410e10bdf00310c1cf2b649bf268f6d
|
|
| BLAKE2b-256 |
48277511681269f3df559d42ca06112f873488d7f0db20b9276d473170fb3592
|
File details
Details for the file zmesh-0.4.0-cp27-cp27m-manylinux1_x86_64.whl.
File metadata
- Download URL: zmesh-0.4.0-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 902.1 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9d6839d72b4a55c5850962665cbd1a219289b9b9b4c82a03cb1fae30a08912b
|
|
| MD5 |
71fe23accea509bf0b361736329f6f13
|
|
| BLAKE2b-256 |
db8553dd136e20de06cee7f46dd9c5cb0ec660dfc27fb8b31f8ad90a2125fc52
|
File details
Details for the file zmesh-0.4.0-cp27-cp27m-macosx_10_14_intel.whl.
File metadata
- Download URL: zmesh-0.4.0-cp27-cp27m-macosx_10_14_intel.whl
- Upload date:
- Size: 245.6 kB
- Tags: CPython 2.7m, macOS 10.14+ Intel (x86-64, i386)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2db76758cd715365f797e4400d85264631cb6dd6d339daaf6a0b89c155c191f1
|
|
| MD5 |
a0493426c0152d845b58da061bfd0a2c
|
|
| BLAKE2b-256 |
43724fa0f0b4f38931be41fee21a651c92bfcd9a9ff603f1254f050e95aeebd1
|