# how to apply MIP on 2D DICOM

**URL:** https://discourse.vtk.org/t/how-to-apply-mip-on-2d-dicom/725
**Category:** Support
**Created:** [April 10, 2019, 8:56am UTC](https://discourse.vtk.org/t/how-to-apply-mip-on-2d-dicom/725 "2019-04-10T08:56:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Aravind](https://discourse.vtk.org/user_avatar/discourse.vtk.org/aravind/32/1070_2.png) [@Aravind](https://discourse.vtk.org/u/Aravind)
#### Post date: [April 10, 2019, 8:56am UTC](https://discourse.vtk.org/t/how-to-apply-mip-on-2d-dicom/725/1 "2019-04-10T08:56:28Z")

</div>

Hello - I am trying to do a MIP on the DICOM images. Not sure what I am doing wrong any help would be appreciated. Here is my code. I am unable to set up the pipeline I believe to scroll through the stack with the MIP.

I am using a NIFTI image reader to read the volume.

PathDicom = “/Desktop/TempDICOM/0/0.nii”  
reader = vtk.vtkNIFTIImageReader()  
reader.SetFileName(PathDicom)  
reader.Update()

# I then get the centre of the volume which is required to set the plane

center = reader.GetOutput().GetCenter()

# I do a histogram range that can be set to the image for viewing.

hist = vtk.vtkImageHistogramStatistics()  
hist.SetInputConnection(reader.GetOutputPort())  
hist.Update()  
hist\_range = hist.GetAutoRange()

# I create a lookup table

lut = vtk.vtkLookupTable()  
ctf = vtk.vtkColorTransferFunction()  
ctf.SetColorSpaceToDiverging()  
ctf.AddRGBPoint(0, 0, 0, 0)  
ctf.AddRGBPoint(1, 1, 1, 1)  
lut.SetNumberOfTableValues(256)  
lut.Build()  
for i in range(0, 256):  
rgb = list(ctf.GetColor(float(i) / 256)) + [1]  
lut.SetTableValue(i, rgb)

#now I set the lookup table  
lut.SetTableRange(hist\_range[0], hist\_range[1])  
lut.SetSaturationRange(0, 0)  
lut.SetHueRange(0, 1)  
lut.SetValueRange(0, 1)  
lut.SetNumberOfColors(256)  
lut.Build()

# I create a plane, with the centre as the origin

plane = vtk.vtkPlane()  
plane.SetOrigin(center)

#use imagereslicemapper to create MIP  
imageResliceMapper = vtk.vtkImageResliceMapper()  
imageResliceMapper.SetInputConnection(reader.GetOutputPort())  
imageResliceMapper.SetSlicePlane(plane)  
imageResliceMapper.SetSlabThickness(3)  
imageResliceMapper.SetSlabTypeToMin()  
imageResliceMapper.SetSlabSampleFactor(1)  
imageResliceMapper.ResampleToScreenPixelsOff()

#I am using VTKImageviewer2 for visualisation  
imageViewer = vtk.vtkImageViewer2()  
imageViewer.SetInputConnection(reader.GetOutputPort())

#set the imagereslicemapper to the imageviewer2  
imageViewer.GetImageActor().SetMapper(imageResliceMapper)

#set the lookuptabla to the imageviewer2  
imageViewer.GetWindowLevel().SetLookupTable(lut)

#set the slice to be viewed  
imageViewer.SetSlice(60)

#initiate renderer and renwin  
renderWindowInteractor = vtk.vtkRenderWindowInteractor()  
imageViewer.SetupInteractor(renderWindowInteractor)  
imageViewer.Render()  
imageViewer.GetRenderer().ResetCamera()  
imageViewer.Render()  
renderWindowInteractor.Start()

---

<div class="post-metadata">

### Author: ![ss59](https://discourse.vtk.org/user_avatar/discourse.vtk.org/ss59/32/3666_2.png) [@ss59](https://discourse.vtk.org/u/ss59)
#### Post date: [April 22, 2019, 7:34am UTC](https://discourse.vtk.org/t/how-to-apply-mip-on-2d-dicom/725/2 "2019-04-22T07:34:26Z")

</div>

Hello Aravind,  
I have got the similar problem.I have tried the same things. When I changed the scrollbar position, Frame wasn’t slicing. I have only one mip dicom image. I want to use with Scrollbar for change diffrent MIP dicom images.  
Did you solve this problem?
