JuliaGeometry / JuliaGeometry/Meshing.jl
Fully de-duplicate vertices in MarchingCube algorithm
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 67
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Recently I started using Meshing.isosurface(), with MarchingCubes as method. The docs say that
setting reduceverts=true (default: true) will merge vertices within a voxel to reduce mesh size by around 30%
and with slight performance improvement.
I called both Meshing.isosurface() and skimage.measure.marching_cubes_lewiner(), a Python function from scikit-image,
to extrude a brain within a volumetric data of size (91, 109, 91).
The number of vertices of the corresponding mesh, returned by Meshing function is (345752) almost 4 times greater
than that returned by skimage function (86473).
345752/86473 = 3.99, i.e. it is exaggerated.
Here are the two blocks of code:
using Meshing
using NPZ
brain_vol = npzread("MNI152.npy") # https://github.com/empet/Datasets/blob/master/MNI152.npy
verts, triangles = isosurface(brain_vol, MarchingCubes(iso=1.25, reduceverts=true, eps=1e-05))
length(verts), length(triangles)
(345752, 172932)
#unique vertices:
uni_verts = unique(i -> verts[i], 1:length(verts))
length(uni_verts)
89264
respectively:
import numpy as np
from skimage import measure
brain_vol= np.load("MNI152.npy")
verts, triangles = measure.marching_cubes_lewiner(brain_vol, 1.25)[:2]
len(verts), len(triangles)
(86473, 173070)
The corresponding Jupyter Notebook has the size of 111MB, vs 25MB, when using Python scikit-image.
Otherwise the mesh plot is great in both cases:

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Meshing.isosurface with MarchingCubes(iso=1.25, reduceverts=true, eps=1e-05) and reproduce the reported vertex counts using the linked MNI152.npy data. Compare the returned verts with the unique-vertex count and the scikit-image marching_cubes_lewiner result; done means reduceverts fully deduplicates shared vertices without invalidating the triangles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia, numpy, python
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100