# 3D model -\> DICOM/nii conversion

**URL:** <https://discourse.itk.org/t/3d-model-dicom-nii-conversion/3536>\
**Category:** Algorithms\
**Tags:** dicom, mesh\
**Created:** [October 14, 2020, 2:49pm UTC](https://discourse.itk.org/t/3d-model-dicom-nii-conversion/3536 "2020-10-14T14:49:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![a10227](https://discourse.itk.org/user_avatar/discourse.itk.org/a10227/32/1690_2.png) [@a10227](https://discourse.itk.org/u/a10227)\
**Post date:** [October 14, 2020, 2:49pm UTC](https://discourse.itk.org/t/3d-model-dicom-nii-conversion/3536/1 "2020-10-14T14:49:57Z")

</div>

Good day,  
I have raw patient images as well as their segmentations as 3D models. I need to convert segmentations to 3D image so that this converted image will be aligned with the patient’s one.  
Could you please tell me, is it possible to convert 3D mesh(.ply) to the DICOM or any other format for 3D images? And is it possible to align it with the other DICOM image?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [October 14, 2020, 9:01pm UTC](https://discourse.itk.org/t/3d-model-dicom-nii-conversion/3536/2 "2020-10-14T21:01:47Z")

</div>

If you need to convert a small number of files, 3D Slicer is a great choice. It [reads STL](https://www.slicer.org/wiki/Documentation/4.10/SlicerApplication/SupportedDataFormat). And somebody already established a [series of steps](https://discourse.slicer.org/t/process-to-import-an-stl-file-and-convert-export-a-series-of-dicom-files/9906/9) for this.

If you need automated conversion, you could adapt this [ITK example](https://itk.org/ITKExamples/src/Core/Mesh/ConvertTriangleMeshToBinaryImage/Documentation.html).

---

<div class="post-metadata">

**Author:** ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)\
**Post date:** [October 14, 2020, 10:02pm UTC](https://discourse.itk.org/t/3d-model-dicom-nii-conversion/3536/3 "2020-10-14T22:02:44Z")

</div>

I used VTK’s vtkPolyDataToImageStencil filter to do it:  
[https://vtk.org/doc/nightly/html/classvtkPolyDataToImageStencil.html](https://vtk.org/doc/nightly/html/classvtkPolyDataToImageStencil.html)

Here’s an example that uses it:  
[https://lorensen.github.io/VTKExamples/site/Python/PolyData/PolyDataToImageDataStencil/](https://lorensen.github.io/VTKExamples/site/Python/PolyData/PolyDataToImageDataStencil/)

---

<div class="post-metadata">

**Author:** ![a10227](https://discourse.itk.org/user_avatar/discourse.itk.org/a10227/32/1690_2.png) [@a10227](https://discourse.itk.org/u/a10227)\
**Post date:** [October 15, 2020, 10:13am UTC](https://discourse.itk.org/t/3d-model-dicom-nii-conversion/3536/4 "2020-10-15T10:13:49Z")

</div>

Thank you for the reply! I will take a look

---

<div class="post-metadata">

**Author:** ![a10227](https://discourse.itk.org/user_avatar/discourse.itk.org/a10227/32/1690_2.png) [@a10227](https://discourse.itk.org/u/a10227)\
**Post date:** [October 15, 2020, 10:14am UTC](https://discourse.itk.org/t/3d-model-dicom-nii-conversion/3536/5 "2020-10-15T10:14:38Z")

</div>

Thank you, I will check this
