Ricardo C.
Ricardo C.

Reputation: 59

Python: Mesh a voxels assembly to compute the surface area

I have a voxels assembly which represents a stone in 3D. It's a binarized numpy 3D array in which 1 is assigned to voxels which make up my stone and 0 elsewhere. I want to:

  1. create its meshed surface
  2. calculate the surface area on it.

But how?

Upvotes: 2

Views: 3444

Answers (2)

Ricardo C.
Ricardo C.

Reputation: 59

I solved my problem if it can be usefull. Marching Cubes algorithm is good, but it doesn't work well on binarized arrays. So: 1) Gaussian Filter applied to the 3D array (scipy.filters) 2) Marching Cubes algorithm to mesh it (scikit-image tool) 3) Sum up the areas of triangles (scikit-image tool)

Upvotes: 2

Juan Leni
Juan Leni

Reputation: 7608

I can see a few options depending on your application: 3D convex hull or marching cubes.

3D convex hull

First, you will need to obtain an array of all the voxel 3D coordinates where your array is equal to 1

Later, you can use scipy.spatial.ConvexHull. Scipy methods are basically a wrapper for the qhull library. When using qhull, one of the output options (FA) is to compute total area and volume.

You can find some more information here: http://scipy.github.io/devdocs/generated/scipy.spatial.ConvexHull.html http://www.qhull.org/html/qconvex.htm

Marching Cubes

If you need to keep concavities, then the previous option will not be enough. Marching cubes will be a good alternative. There is already a python implementation in scikit-image.

http://scikit-image.org/docs/dev/auto_examples/plot_marching_cubes.html

You will again need to obtain all points as in the previous case. You calculate the verbs/faces with:

http://scikit-image.org/docs/dev/api/skimage.measure.html#marching-cubes

And the you can calculate the area with:

http://scikit-image.org/docs/dev/api/skimage.measure.html#mesh-surface-area

Upvotes: 3

Related Questions