processing medical data it's actually somewhat normal to turn your medical data into 3d models and then e.g. 3d print copies of yourself or your bones or bodyparts or fossils or anything put through a medical scanner, apparently (this turns up when websearching turning medical formats into 3d models) it looks like there are basically two major DICOM data libraries, dcmtk and gcdm . there's a small list of public data and libraries at https://github.com/open-dicom/awesome-dicom . i loaded some data (from my cancer treatment) into an open source viewer called amide, based on dcmtk, which i built from source laboriously with dependencies -- but amide doesn't let you export 3d models like other viewers do presently poking at DicomToMesh ( https://github.com/eidelen/DicomToMesh ) from the awesome-dicom link above. DicomToMesh depends on VTK ( https://gitlab.kitware.com/vtk/vtk.git ) as well as an auxiliary library called vtkDicom ( https://github.com/dgobbi/vtk-dicom ) that must be manually enabled which then in turn can link to either DCMTK or GCDM if configured to. Unless you jump through all the hoops, DicomToMesh only loads very simple datasets. When using amide or its dependency dcmtk, one specifies the DICOMDIR file; but with DicomToMesh and vtkDicom, instead one specifies the path to the root folder of the media disk. It looks like VTK 9.3 needs to be built with -DVTK_ENABLE_REMOTE_MODULES=YES -DVTK_MODULE_ENABLE_VTK_vtkDICOM=YES to include vtk-dicom that can load more datasets. The first flag needs to be enabled prior to cmake's run or the second flag isn't recognised, because the first is used before its declaration. ( troubleshooted via Remote/vtkDICOM.remote.cmake in the VTK source tree; this file also has the git url in it that the build will clone from.) Additionally, one must set -DUSE_DCMTK=ON or -DUSE_GDCM=ON to be able to load any compressed data using a general-purpose dicom library, and these other flags also only appear if the previous two flags are enabled and the remote vtk-dicom module cloned by the build. The DicomToMesh instructions say to also pass -DVTK_MODULE_ENABLE_VTK_DICOM=YES ; this is maybe an old name for the module. I also ran into a build error until I modified the -DENABLE_SHARED build flag of VTK and DCMTK to match, and I had to wipe my CMakeCache.txt and repass all the flags for this change to take. $ dicom2mesh -h How to use dicom2Mesh: Minimum example. This transforms a dicom data set into a 3d mesh file called mesh.stl by using a default iso value of 400 (shows bone)
dicom2mesh -i pathToDicomDirectory -o mesh.stl
This creates a mesh file in a binary format called mesh.stl
dicom2mesh -i pathToDicomDirectory -b -o mesh.stl
This creates a mesh file called abc.obj by using a custom iso value of 700
dicom2mesh -i pathToDicomDirectory -o abc.obj -t 700
This creates a mesh file by using a iso value range of 500 to 900
dicom2mesh -i pathToDicomDirectory -o abc.obj -t 500 -tu 900
This option offers the possibility to crop the input dicom volume. The created mesh is called def.ply.
dicom2mesh -i pathToDicomDirectory -z -o def.ply
This creates a mesh with a reduced number of polygons by 50% as default
dicom2mesh -i pathToDicomDirectory -r
This creates a mesh with a reduced number of polygons by 80%
dicom2mesh -i pathToDicomDirectory -r 0.8
This creates a mesh with a limited number of polygons of 10000. This has the same effect as reducing -r the mesh. It does not make sense to use these two options together.
dicom2mesh -i pathToDicomDirectory -p 10000
This creates a mesh where small connected objects are removed. In particular, only connected objects with a minimum number of vertices of 20% of the object with the most vertices are part of the result.
dicom2mesh -i pathToDicomDirectory -e 0.2
This creates a mesh which is shifted to the coordinate system origin.
dicom2mesh -i pathToDicomDirectory -c
This creates a mesh which is smoothed.
dicom2mesh -i pathToDicomDirectory -s
This creates a mesh and shows it in a 3d view.
dicom2mesh -i pathToDicomDirectory -v
This shows the dicom data in a volume render [ (Red,Green,Blue,Alpha,Iso-Value) ].
dicom2mesh -i pathToDicomDirectory -vo (255,0,0,0,0) (255,255,255,60,700) ...
Alternatively a mesh file (obj, stl, ply) can be loaded directly, modified and exported again. This is handy to modify an existing mesh. Following example centers and saves a mesh as cba.stl.
dicom2mesh -i abc.obj -c -o cba.stl
A mesh can be created based on a list of png-file slices as input. The three floats followed after -sxyz are the x/y/z-spacing.
dicom2mesh -ipng [path1, path2, path3, ...] -sxyz 1.5 1.5 3.0 -c -o cba.stl
Arguments can be combined. Here's a screenshot from the default output of dicom2mesh -v now that i finally got it to build at the end of the day. This is my living skull as it was in 2019, reconstructed from cancer monitoring imagery.