AttributeError: module 'skimage.measure' has no attribute 'marching_cubes'

Viewed 11082

when I'm executing one of code that I found from the web it's given me "AttributeError: module 'skimage.measure' has no attribute 'marching_cubes'". Do you have any idea to fix this?

Executed code segment:

from skimage import measure
def make_mesh(image, threshold=+30, step_size=1):
 print "Transposing surface"


p = image.transpose(2, 1, 0)

print "Calculating surface"
verts, faces, norm, val = measure.marching_cubes(p, threshold, step_size=step_size, allow_degenerate=True)
return verts, faces
3 Answers

In the new version, there are two methods marching_cubes_lewiner and marching_cubes_classic. But classic doesn't take step_size parameter. You can try this:

measure.marching_cubes_lewiner(p, threshold, step_size=step_size, allow_degenerate=True)

I've used the marching_cubes_lewiner function to solve the problem. Please refer following code line.

print("Calculating surface")
verts, faces, norm, val = measure.marching_cubes_lewiner(p, threshold, step_size=step_size, allow_degenerate=True)
return verts, faces

You can use marching_cubes_classic(p, threshold)

Related