I have 2D CT images in a 3D numpy of shape [512, 512, 586]
(or a bunch of jpeg files saved from this array). Those images have only two pixels values: 0 or 255
what I need to do is to convert this array into a printable 3D model/mesh (STL or whatever is possible)
I tried what was described in this post using simple itk. However I didn't find anything about saving the volume into a stl file
is there a way to do this? (using simple itk or any other library)
--EDIT-- so here is my code using VTK, however i'm having trouble to convert the numpy array to a vtk array
dataImporter = vtk.vtkImageImport()
data_string = ArrayDicom.tostring()
dataImporter.CopyImportVoidPointer(data_string, len(data_string))
dataImporter.SetDataScalarTypeToUnsignedShort()
dataImporter.SetNumberOfScalarComponents(1)
dataImporter.SetDataExtent(0, heightArray-1, 0, depthArray-1, 0, widthArray-1)
dataImporter.SetWholeExtent(0, heightArray-1, 0, depthArray-1, 0, widthArray-1)
this code is showing a black window with nothing inside it
The other code:
print("converting numpy array to VTK array")
CT_Data = reader.GetOutput()
NP_data = numpy_support.numpy_to_vtk(ArrayDicom.ravel(), deep=True, array_type=vtk.VTK_TYPE_INT16)
print("loading vtkImageData")
imageVTK = vtk.vtkImageData()
imageVTK.SetSpacing(CT_Data.GetSpacing())
imageVTK.SetOrigin(CT_Data.GetOrigin())
imageVTK.SetDimensions(CT_Data.GetDimensions())
imageVTK.GetPointData().SetScalars(NP_data)
dmc = vtk.vtkDiscreteMarchingCubes
dmc.SetInputData(imageVTK)
this one is getting the error : TypeError: no overloads of SetInputData() take 0 arguments