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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With