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.vertices
mesh.faces
mesh.normals
# 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 and Nico Kemnitz.
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
zmesh-0.3.0.tar.gz
(250.6 kB
view hashes)
Built Distributions
Close
Hashes for zmesh-0.3.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ac76e78c304a1ac41b790b027691936f9c7c5e5d7e372cfab7fc082fcd5b1bd |
|
MD5 | 58d5a2956ea4cc2722af3534438fe794 |
|
BLAKE2b-256 | 428546bdae0521d847274a7adb6075bb778ae627a42535cb1ccd9cf3b21eac9a |
Close
Hashes for zmesh-0.3.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6421c50c396038e290a3041cd22c205fc4881629594fc0082216c23a1f3c002f |
|
MD5 | a45d992e2dc7749b265875c9a0d0003d |
|
BLAKE2b-256 | a2e5ef380c184e374a4f4c3763177c4b904ee52896c5b2f6176ba4ea8a40d20d |
Close
Hashes for zmesh-0.3.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9796dae3f416158be66b39bfc2c3fd2159e36dcf8aac7fd9694294c910837029 |
|
MD5 | a43c7b6f553d0f227502d440c513ceca |
|
BLAKE2b-256 | fa9ebfcd723495823565af9573b4c818c3ad0abc4c3ff0ff7eb183b88a75b0ca |
Close
Hashes for zmesh-0.3.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ab7b1174e21b0e7cf38cb2063ef765f5842f20484866843b16d91d73b7622b3 |
|
MD5 | 42b878220e7df1703b7cc64323246aec |
|
BLAKE2b-256 | d8d40063e12577ea7ef5b39979510e9622d5b280c65f230d2adbf1e726dc4bf3 |
Close
Hashes for zmesh-0.3.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 433a281d7d519f932369f8b8ab0ad2d807780598372b6a274a09397ddfa63105 |
|
MD5 | 2b301f3c562290a45721e32d0c685d1e |
|
BLAKE2b-256 | 8f6da383fb3ece856b89a8aed42fb5d94a876fa0e03b7ba34db9bb2a245d7f40 |
Close
Hashes for zmesh-0.3.0-cp27-cp27m-macosx_10_14_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cb19c371cbb83fa7f0a2914bf8af3e429d8015b82b2d948d237a5ad22d5130d |
|
MD5 | da00b109960b4176031164cb30acbeb8 |
|
BLAKE2b-256 | 77da85e9c8b9ccca34e1633cb0d2c90a9d684367bdeab7621e4e01321dc28387 |