# Maximum Intensity Projection

**URL:** https://discourse.vtk.org/t/maximum-intensity-projection/6514
**Category:** VR/AR
**Created:** [August 31, 2021, 1:15pm UTC](https://discourse.vtk.org/t/maximum-intensity-projection/6514 "2021-08-31T13:15:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aleena98](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/2acd7d/32.png) [@aleena98](https://discourse.vtk.org/u/aleena98)
#### Post date: [August 31, 2021, 1:15pm UTC](https://discourse.vtk.org/t/maximum-intensity-projection/6514/1 "2021-08-31T13:15:09Z")

</div>

I am working on a project to detect cerebral aneurysm using UNET CNN. I am using MRA images in this project. I would need to convert the 3D images into 2D images before feeding it into the neural network or get MIP for the images. How can I use VTK for this

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 31, 2021, 6:07pm UTC](https://discourse.vtk.org/t/maximum-intensity-projection/6514/2 "2021-08-31T18:07:10Z")

</div>

To generate MIP images, you have two options:

- volume rendering (vtkGPUVolumeRayCastMapper): disable shading, choose [MIP blend mode](https://vtk.org/doc/nightly/html/classvtkVolumeMapper.html#aac00c48c3211f5dba0ca98c7a028e409), you can generate hundreds of MIPs per second on a modern GPU
- thick slab reslicing (vtkImageSlabReslice): it may is slow (may take several seconds to render a single image), but it does not require GPU, runs on any volume size that fits into your RAM, and can accumulate data at higher bit depth than just 8 bits per pixel.

---

<div class="post-metadata">

### Author: ![arturpol94](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/90ced4/32.png) [@arturpol94](https://discourse.vtk.org/u/arturpol94)
#### Post date: [August 18, 2022, 8:49pm UTC](https://discourse.vtk.org/t/maximum-intensity-projection/6514/3 "2022-08-18T20:49:34Z")

</div>

@lassoan

I want to load a CT, reproject it with MIP and load it into slicer scene. Here is my code.

reader = vtk.vtkDataReader()  
reader.SetFileName(‘…’)  
reader.Update()

volumeMapper = vtk.vtkGPUVolumeRayCastMapper()  
volumeMapper.SetInputConnection(reader.GetOutputPort())  
volumeMapper.SetSampleDistance(0.01)  
volumeMapper.SetBlendModeToMaximumIntensity()

volume = vtk.vtkVolume()  
volume.SetMapper(volumeMapper)

reprojection = slicer.mrmlScene.AddNewNodeByClass(“vtkMRMLVolumeNode”, “reprojection”)

My question is how do I load volume into reprojection?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 18, 2022, 9:06pm UTC](https://discourse.vtk.org/t/maximum-intensity-projection/6514/4 "2022-08-18T21:06:25Z")

</div>

You can get rendering result into a vtkImageData using vtkWindowToImageFilter.

---

<div class="post-metadata">

### Author: ![arturpol94](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/90ced4/32.png) [@arturpol94](https://discourse.vtk.org/u/arturpol94)
#### Post date: [September 21, 2022, 2:01pm UTC](https://discourse.vtk.org/t/maximum-intensity-projection/6514/5 "2022-09-21T14:01:12Z")

</div>

thanks a lot @lassoan

Another question.  
I need the MIP in the coronal plane of a CT. I know I could use the Volume Rendering Module and take the screenshot of the 3D view. But is there an option to set that orientation directly at vtkGPUVolumeRayCastMapper?

thanks

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [October 6, 2022, 8:56pm UTC](https://discourse.vtk.org/t/maximum-intensity-projection/6514/6 "2022-10-06T20:56:02Z")

</div>

The `vtkGPUVolumeRayCastMapper` is only responsible for computing pixel values, so you cannot set anything related to orientation there. The orientation the volume shows up in the renderd image is determined by the volume actor and the camera.
