# Digitally Reconstructed Radiograph Using Models Instead of Volumes

**URL:** <https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309>\
**Category:** Support\
**Created:** [June 26, 2018, 6:16pm UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309 "2018-06-26T18:16:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_jmichael](https://avatars.discourse-cdn.com/v4/letter/_/ce7236/32.png) [@\_jmichael](https://discourse.slicer.org/u/_jmichael)\
**Post date:** [June 26, 2018, 6:16pm UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309/1 "2018-06-26T18:16:04Z")

</div>

Is it possible using Slicer to create a simulated x-ray image, similar to a digitally reconstructed radiograph, that takes 3D models as its input rather than volumetric data (i.e. CT scans)? I’m envisioning a scenario in which 3D models (e.g. STL files) of one or more bones/implants/tools etc. can be placed in a 3D scene, assigned x-ray attenuation values, and an x-ray image simulated? Solutions that require the use of python are viable options for me.

I know it’s possible to generate a digitally reconstructed radiograph from a CT scan as per the post linked to below, but wasn’t sure if it’s possible to do that using a more simplified model of a finite number of structures each with constant x-ray attenuation. I know it’s possible to convert surface models to volumetric data and then generate a DRR of those volumes, but that seems like a fairly inefficient solution (computationally) compared to something that can calculate ray-triangle intersections directly.

Thanks in advance for your help!

> [@Generate digitally reconstructed radiograph from 3DCT](https://discourse.slicer.org/t/generate-digitally-reconstructed-radiograph-from-3dct/2010):
>
> Hello again, I would like to create some digitally reconstructed radiographs (DRR) in slicer from come 3DCt data that I have to compare to actual radiograph images that I have acquired. I saw one thread here: that talked about how to do it. At the end, Andras suggested installing the plastimatch module for more realistic DRR generation. I did install this extension (well I installed slicerRT which contains the plastimatch module) but I didn’t see the option anywhere to create a DRR. Ideally…

---

<div class="post-metadata">

**Author:** ![Hamburgerfinger](https://avatars.discourse-cdn.com/v4/letter/h/eb9ed0/32.png) [@Hamburgerfinger](https://discourse.slicer.org/u/Hamburgerfinger)\
**Post date:** [June 27, 2018, 1:22am UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309/2 "2018-06-27T01:22:07Z")

</div>

![22%20PM](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/d/3dd5b2d51dc4504e200cee756186bc8374b13386.png)

Try this out… seems to work reasonably well, but not sure if it qualifies as a “simulation”.

Create an empty image volume with Image Maker module. Then import your .stl files or whatever and convert to segmentation (Segmentation module → import models). Fill the voxels in the empty image volume with values for the linear attenuation coefficient (look these up for e.g. bone, soft tissue, lung tissue at the photon energy you’re interested in… here I used 10 kVp and looked up the values from the NIST database), for each tissue; you could script it or use a combination of Segmentations → “Mask Volume” and Add Scalar Volumes module in the GUI. Finally, once you have your linear attenuation coefficient map (image) completed, use Simple Filters module → MeanProjectionImageFilter, or SumProjectionImageFilter.

The result is at the bottom right.

Best,  
Luke

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 27, 2018, 7:23am UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309/3 "2018-06-27T07:23:56Z")

</div>

There are many options how to do this. The ideal solution depends on what your requirements are (how many input models you have, what resolution you need, how quickly the objects move, how complex their geometry is, what CPU and GPU are available, etc.).

@Hamburgerfinger’s suggestion is good. Generating binary or fractional volumes and render it using GPU is good, too (after the volumes are generated, GPU renderer can probably render the DRR image at a high frame rate).

---

<div class="post-metadata">

**Author:** ![\_jmichael](https://avatars.discourse-cdn.com/v4/letter/_/ce7236/32.png) [@\_jmichael](https://discourse.slicer.org/u/_jmichael)\
**Post date:** [June 27, 2018, 3:43pm UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309/4 "2018-06-27T15:43:59Z")

</div>

Perfect. Thanks @lassoan and @Hamburgerfinger!

---

<div class="post-metadata">

**Author:** ![Jan\_Alexander](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jan_alexander/32/6831_2.png) [@Jan\_Alexander](https://discourse.slicer.org/u/Jan_Alexander)\
**Post date:** [May 13, 2020, 4:35pm UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309/5 "2020-05-13T16:35:02Z")

</div>

Hi,

For me this is still unclear. I cannot find a module named ‘Image Maker’. I have no idea how I should create an empty volume and there is no clear explanation how to do this. I imported my .stl and exported this as a binary labelmap. Now I can find this back in the volume module. I cannot set any linear attenuation coefficient values though.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 16, 2020, 7:27pm UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309/6 "2020-05-16T19:27:17Z")

</div>

You are almost there. You can already generate a DRR from this using Volume Rendering module. To make it look more realistic, you need to adjust transfer functions, which might be a bit hard if your voxel values are 0 and 1 (defaults for binary labelmaps).

I would recommend to convert the labelmap volume to scalar volume in Volumes module, then replace labelmap values by Hounsfield unit values (e.g., air -1000, bones and tools around 1000-2000) and add some noise using numpy. See this example for details:  
[https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Add\_noise\_to\_image](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Add_noise_to_image)

You can change label value 3 to Hounsfield unit 1200 by calling `voxels[voxels==3] = 1200`.

---

<div class="post-metadata">

**Author:** ![phantom\_gen](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@phantom\_gen](https://discourse.slicer.org/u/phantom_gen)\
**Post date:** [November 12, 2024, 11:42am UTC](https://discourse.slicer.org/t/digitally-reconstructed-radiograph-using-models-instead-of-volumes/3309/7 "2024-11-12T11:42:17Z")

</div>

![middeslab_projektion simpel](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/c/1c0f0942399a0c3e194f6df46f270a81d17e161e.png)

Hi Guys! Although this is an older topic I thought I give it a try since I have a similiar question:

The uploaded picture is an orthographic projection of a STL Design I did, which shall mimic a female breast parenchym in Mammography. I created the projection using an orthographic projection script in python.  
So much for the introduction, now here is my problem: I want to use 3D slicer to create a more advanced orthographic projection, like a DRR. I have voxelized the STL file and want every voxel that is filled, to have a certain attenuation A, and all the space inbetween (so all empty voxels) to have a certain attenuation B. Thanks in advance for your help!
