From ededdfaf56d6f7d07ae171310dc701601adec45f Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 25 May 2016 10:53:06 +0200 Subject: [PATCH] improve docs and acks related to new MC alg --- CONTRIBUTORS.txt | 3 +++ skimage/measure/_marching_cubes_lewiner.py | 14 ++++++++------ skimage/measure/mc_meta/visual_test.py | 4 ++-- skimage/measure/tests/test_marching_cubes.py | 1 + 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index e4c852e6..921a2b1b 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -230,6 +230,9 @@ - Alex Izvorski Color spaces for YUV and related spaces +- Thomas Lewiner + Design and original implementation of the Lewiner marching cubes algorithm + - Jeff Hemmelgarn Minimum threshold diff --git a/skimage/measure/_marching_cubes_lewiner.py b/skimage/measure/_marching_cubes_lewiner.py index 7f8339e5..ab5976af 100644 --- a/skimage/measure/_marching_cubes_lewiner.py +++ b/skimage/measure/_marching_cubes_lewiner.py @@ -52,7 +52,9 @@ def marching_cubes_lewiner(volume, level=None, spacing=(1., 1., 1.), If given and True, the classic marching cubes by Lorensen (1987) is used. This option is included for reference purposes. Note that this algorithm has ambiguities and is not guaranteed to - produce a topologically correct result. + produce a topologically correct result. The results with using + this option are *not* generally the same as the ``marching_cubes()`` + function. Returns ------- @@ -74,11 +76,11 @@ def marching_cubes_lewiner(volume, level=None, spacing=(1., 1., 1.), Notes about the algorithm ------------------------- - The algorithm [1] is an improved version of Chernyaev's Marching Cubes 33 - algorithm, originally written in C++. It is an efficient algorithm - that relies on heavy use of lookup tables to handle the many different - cases. This keeps the algorithm relatively easy. The current algorithm - is a port of Lewiner's algorithm and written in Cython. + The algorithm [1] is an improved version of Chernyaev's Marching + Cubes 33 algorithm. It is an efficient algorithm that relies on + heavy use of lookup tables to handle the many different cases, + keeping the algorithm relatively easy. This implementation is + written in Cython, ported from Lewiner's C++ implementation. References ---------- diff --git a/skimage/measure/mc_meta/visual_test.py b/skimage/measure/mc_meta/visual_test.py index e8b7e717..f04ade92 100644 --- a/skimage/measure/mc_meta/visual_test.py +++ b/skimage/measure/mc_meta/visual_test.py @@ -27,7 +27,7 @@ elif SELECT == 2: isovalue = 0.2 elif SELECT == 3: - # Generate two donuts + # Generate two donuts using a formula by Thomas Lewiner n = 48 a, b = 2.5/n, -1.25 isovalue = 0.0 @@ -53,7 +53,7 @@ elif SELECT == 4: # Get surface meshes t0 = time.time() -vertices1, faces1, *_ = marching_cubes_lewiner(vol, isovalue, gradient_direction=gradient_dir, use_classic=False) +vertices1, faces1, *_ = marching_cubes_lewiner(vol, isovalue, gradient_direction=gradient_dir, use_classic=True) print('finding surface lewiner took %1.0f ms' % (1000*(time.time()-t0)) ) t0 = time.time() diff --git a/skimage/measure/tests/test_marching_cubes.py b/skimage/measure/tests/test_marching_cubes.py index 25262682..e46a4207 100644 --- a/skimage/measure/tests/test_marching_cubes.py +++ b/skimage/measure/tests/test_marching_cubes.py @@ -138,6 +138,7 @@ def test_both_algs_same_result_donut(): for iz in range(vol.shape[0]): for iy in range(vol.shape[1]): for ix in range(vol.shape[2]): + # Double-torii formula by Thomas Lewiner z, y, x = float(iz)*a+b, float(iy)*a+b, float(ix)*a+b vol[iz,iy,ix] = ( ( (8*x)**2 + (8*y-2)**2 + (8*z)**2 + 16 - 1.85*1.85 ) * ( (8*x)**2 +