Multilabel marching cubes and simplification of volumetric data.
Reason this release was yanked:
Segfault found.
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
# 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 domesher.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
- 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)
- 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)
- 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
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-1.6.0.tar.gz
(352.0 kB
view hashes)
Built Distributions
zmesh-1.6.0-cp310-cp310-win_amd64.whl
(247.2 kB
view hashes)
zmesh-1.6.0-cp39-cp39-win_amd64.whl
(247.2 kB
view hashes)
zmesh-1.6.0-cp38-cp38-win_amd64.whl
(247.0 kB
view hashes)
zmesh-1.6.0-cp37-cp37m-win_amd64.whl
(245.0 kB
view hashes)
zmesh-1.6.0-cp36-cp36m-win_amd64.whl
(244.8 kB
view hashes)
Close
Hashes for zmesh-1.6.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2f15861d197e6aa1faf3396441e4c439f7395c3628d189933be7a5df3b2917e |
|
MD5 | cb93cabefd3eb81cd6aec000b98ce054 |
|
BLAKE2b-256 | 9165d72672c760dac63a23846c4d8cc381a04bb40fe136a36640b6ee7b22e5e6 |
Close
Hashes for zmesh-1.6.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55783a91113bb07a155e569573d7f4a95224b11af483c167e538f3ae2cc7a258 |
|
MD5 | 97452382ca3b3af1eabbb928bbf45f66 |
|
BLAKE2b-256 | 57e885b8741e3c5f2501f3b1e73c412ab1a428b618ee24e5ca1d478ba3fc6698 |
Close
Hashes for zmesh-1.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52f6c133b76586941a94e1a114ccc200413df1af91fb5b66d8dcc35f0c7a8594 |
|
MD5 | 757888569dafaadeb49e6a2ebc297187 |
|
BLAKE2b-256 | 95aca6d7039c3eccc5a42950ad9f0af285fe34e1c6b3d03983374913e6093ee3 |
Close
Hashes for zmesh-1.6.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5729446cba2921186fabade8430600f377a6cc6af66fa82a2342fd5e6b80e119 |
|
MD5 | e048e02ee341f39be708237dfe92530b |
|
BLAKE2b-256 | f3f8f3b51956d6a535888d9643abcf3ce680a186a694220d577714702c58fdf6 |
Close
Hashes for zmesh-1.6.0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad82db5c65a3148347d219a408ea67385567b4361a667b153218aa6114971e10 |
|
MD5 | 78bb71e9e65c18aa7f9335f933559457 |
|
BLAKE2b-256 | e720cda2cf5c505aa8ddbdf33e0b2330cddcb54330cabd349c2f3352e4a5d879 |
Close
Hashes for zmesh-1.6.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fb7d3f66456081b80df6ae3fef74d43a6542e045246d9aefa007af6ed10491b |
|
MD5 | b43c327dc36d25cc5c4366f94026c6dc |
|
BLAKE2b-256 | 78d16d06f1c40552ecd0461457a69062df3e16f168960a4ec37c3d4e46541f15 |
Close
Hashes for zmesh-1.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 206d190f82f4bf1c22e57fac9b017d32cdf675c90e8ded82d844748007c9b469 |
|
MD5 | f56b5cf64b0e658d89116e3b0518f5a1 |
|
BLAKE2b-256 | 17749449ce9df74d4d36da1569dd56a7716ec4b73dd213d56fa440038da8fc08 |
Close
Hashes for zmesh-1.6.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d465f0a47bc9cd1cfa9dc857ac47f6e883dd61807d8bcdb5423a761dd1c3d9a |
|
MD5 | d7f576ea0baf693204c4718820e14ff6 |
|
BLAKE2b-256 | de58630b08a469e8b1f5ef8a6fbf7e37d593c7bcd41f9a4f62d0f9bf0edf1d96 |
Close
Hashes for zmesh-1.6.0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 550ea4271f34f96793fae9be6fc5c87873b50c37eb82d3982c1fb86f68568933 |
|
MD5 | 03198a8a92a662d8c92679544f46dc7e |
|
BLAKE2b-256 | 769dea679532caca6fd05e5e0816314492d01af426ea11a020b2a4f62e019bb6 |
Close
Hashes for zmesh-1.6.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4204e737a712cdd5e63bfa11d1060f0847936001a06611f6964a793d5df838bd |
|
MD5 | 03c56a04cc9bea6893b93b1d02b6a263 |
|
BLAKE2b-256 | 6767c56f7311e704c528151fd995cdcb2556ee6801c272ee5f6bd444d5215761 |
Close
Hashes for zmesh-1.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0d3b1fdcd6c39c097efc5a714075113dda9734944924f006d1b98724d7c4d13 |
|
MD5 | 1942b45d7ab7f0b8fe797a6d353cde8b |
|
BLAKE2b-256 | 5e743a3eb328d71e9db2c1f647e406e5cba2bf9c0e63df3f851febcab38ebbe5 |
Close
Hashes for zmesh-1.6.0-cp38-cp38-macosx_11_0_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4787d8c5aa0e45d1806ba0edd575bcdec5203cc1533a3ebdf5d95e5c15555ce |
|
MD5 | de1f1eea0f03fa80c23a098357675cef |
|
BLAKE2b-256 | 6777e479a31596ed9b758df179041e9db5381a83c8fd2c67afaaa51b8e3f4d14 |
Close
Hashes for zmesh-1.6.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1c29fd4a4c1fa003444fdda1ccae654ba0c8df933ef579c7d29aac5efa063a2 |
|
MD5 | 022fdb172183d490eed129096e908bc4 |
|
BLAKE2b-256 | 5ab6ae23cf06b60fff0f20dacfbb47586d67998160773bed7bad90944b79bc4e |
Close
Hashes for zmesh-1.6.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c81c325a127899b3213a9441ab2df0e00969dfba3f8d4020d68f16459762d40 |
|
MD5 | 465550851308d33f409b43108a44cca0 |
|
BLAKE2b-256 | 6201292944c1b04a01ebb5a71c52abdcaaab482d3c23a4d604fa0a5f71c69713 |
Close
Hashes for zmesh-1.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d2b15c0f350cf17bff6f3f4b21ace367f5531c5e9f5e2a3daa7a51352d1a79a |
|
MD5 | 65bc86c775b7d2603c39f19e50eedbdb |
|
BLAKE2b-256 | 4d6c00f9801515057def074867348f5b8b4c3150cd4f072c2e9f5e822e078723 |
Close
Hashes for zmesh-1.6.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49e57133c463551026c8f6379fb30711382b4dee9ca43e34aacae931ee1b52b5 |
|
MD5 | 370de221e30ffc89241c17d9406d2943 |
|
BLAKE2b-256 | 51c2ad6a7245f988888ab8ea818e391bbc60db8be2dcc208ec5e2130356dfa0d |
Close
Hashes for zmesh-1.6.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69c795fe886fa7935cf31a3e3d4a7deaa705332ab71bbcdfbd887b2e9c18a605 |
|
MD5 | 6aefb9010411502130311c9e4f705a17 |
|
BLAKE2b-256 | d4e42cc05d712367f8de3dbc27e23c5f452a72a13b7310cbc51eb469a6ded439 |
Close
Hashes for zmesh-1.6.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d6fbb64e8be50821fa053bf0718220749d811b2a907ee1b6598f43ce7c400c |
|
MD5 | a949edec95da54c45613149caf6281f8 |
|
BLAKE2b-256 | fa46691b4ec33e17c48a3b03993446b443b1cd7ac0aa6fe1d90e3094ace63512 |
Close
Hashes for zmesh-1.6.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 292f7295175935fcb45e32f321170633f6d600f8260182a5459b05dab6a9861a |
|
MD5 | e346d85b8c9d162035369148d3036ab6 |
|
BLAKE2b-256 | 0db42b58959c7b4035a09d3198e0450142fd737163a862262a7a8381027b93d1 |