3

I did a 3D segmentation of an organ in a 3D volume of data acquired in CT. The output of the segmentation is defined as a binary 3D ndarray, where 1 is inside the organ, and 0 is outside the organ.

What is the best tool to extract the surface of this object as a mesh, that I can then export into a mesh format such as .stl?

Thanks!

3

1 Answer 1

2

I'm not sure that is a best variant, but there is easy way to do it if use MeshLib.

To install it on Windows use py -3.10 -m pip install --upgrade meshlib

Script to do this will look like:

import meshlib.mrmeshpy as mr
import meshlib.mrmeshnumpy as mrn

#convert 3D array to SimpleVolume data
simpleVolume = mrn.simpleVolumeFrom3Darray(inputData)

#convert SimpleVolume to FloatGrid data
floatGrid = mr.simpleVolumeToDenseGrid(simpleVolume )

#make mesh by iso-value = 0.5 and voxel size = (0.1, 0.1, 0.1)
mesh = mr.gridToMesh(floatGrid , mr.Vector3f(0.1, 0.1, 0.1), 0.5)

#save mesh
mr.saveMesh(mesh, "mesh.stl" )

I hope this helps you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.