# Generate 2D X-ray image from volume, just like DRR

**URL:** <https://discourse.slicer.org/t/generate-2d-x-ray-image-from-volume-just-like-drr/976>\
**Category:** Support\
**Created:** [August 31, 2017, 1:31pm UTC](https://discourse.slicer.org/t/generate-2d-x-ray-image-from-volume-just-like-drr/976 "2017-08-31T13:31:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![langderyos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/langderyos/32/599_2.png) [@langderyos](https://discourse.slicer.org/u/langderyos)\
**Post date:** [August 31, 2017, 1:31pm UTC](https://discourse.slicer.org/t/generate-2d-x-ray-image-from-volume-just-like-drr/976/1 "2017-08-31T13:31:47Z")

</div>

Hi,  
I’m finding a way to generate 2D X-ray image from volume data, just like what DRR does.  
Is there any extension which can do this?Or can I do it in a python way?

thanks  
langderyos,

---

<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:** [August 31, 2017, 1:58pm UTC](https://discourse.slicer.org/t/generate-2d-x-ray-image-from-volume-just-like-drr/976/2 "2017-08-31T13:58:39Z")

</div>

Probably the easiest way to get DRR-like images is to set up thick slice display using Python. For example, copy-paste this code snippets into the Python console to get started:

Maximum intensity projection:

```
sliceNode = slicer.mrmlScene.GetNodeByID('vtkMRMLSliceNodeRed')
appLogic = slicer.app.applicationLogic()
sliceLogic = appLogic.GetSliceLogic(sliceNode)
sliceLayerLogic = sliceLogic.GetBackgroundLayer()
reslice = sliceLayerLogic.GetReslice()
reslice.SetSlabModeToMax()
reslice.SetSlabNumberOfSlices(600)
reslice.SetSlabSliceSpacingFraction(0.5)
sliceNode.Modified()

```

Result for CTChest example data set:

![image_00036](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/9/c9eec191b459a546649043480efe82c708c1be57.png)

You could get more DRR-like image if you change slab mode to mean instead of max (`reslice.SetSlabModeToMean()`), but usually it makes details more difficult to see.

Same data set with DRR-like mean slab mode:

![image_00035](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/1/e1c09bada673304ee908e68ee898b223ca47dd5c.png)

See some more examples [here](http://slicer-devel-archive.65872.n3.nabble.com/Faster-slice-view-thick-slices-and-MIP-slice-view-mode-td4033264.html).

For faster updates and display in 3D view, you can configure Volume rendering module to show a maximum intensity projection (MIP). For most realistic DRR rendering, you can try to use Plastimatch extension.

---

<div class="post-metadata">

**Author:** ![langderyos](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/langderyos/32/599_2.png) [@langderyos](https://discourse.slicer.org/u/langderyos)\
**Post date:** [September 1, 2017, 5:30am UTC](https://discourse.slicer.org/t/generate-2d-x-ray-image-from-volume-just-like-drr/976/3 "2017-09-01T05:30:10Z")

</div>

Hi, Andras

Thanks a lot for your reply! I tried it and find it very helpful for me.But in slicer 4.6.0, there is no content in plastimatch module.Perhaps it’s a problem about version.

thanks again  
langderyos
