Hello there,
I wrote a simple program to render a series of dicom images and it shows a good result for a CT images (exp: CT.dcm) but when i run the same code for series of MRI (MRI.dcm) or Fluorescence (F.dcm) images, i just get white screen. Can anyone suggest me what am i doing wrong?
Size of images are CT : 512 x512, MRI = 192x192, F = 1316x1316
CODE:
import vtk
from vtk.tk.vtkTkRenderWindowInteractor import vtkTkRenderWindowInteractor
input_In = “/Users/Desktop/Temporary_files/Rough-1/Temp/output1/Channel_CZI-0/”
# Load the dataset
reader = vtk.vtkDICOMImageReader()
reader.SetDirectoryName(input_In)
reader.Update()
opacityTransferFunction = vtk.vtkPiecewiseFunction()
opacityTransferFunction.AddPoint(1, 0.0)
opacityTransferFunction.AddPoint(100, 0.1)
opacityTransferFunction.AddPoint(255, 1.0)
colorTransferFunction = vtk.vtkColorTransferFunction()
colorTransferFunction.AddRGBPoint(0.0, 0.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(64.0, 1.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(128.0, 0.0, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(192.0, 0.0, 1.0, 0.0)
colorTransferFunction.AddRGBPoint(255.0, 0.0, 0.2, 0.0)
volumeProperty = vtk.vtkVolumeProperty()
volumeProperty.SetColor(colorTransferFunction)
volumeProperty.SetScalarOpacity(opacityTransferFunction)
volumeProperty.ShadeOn()
volumeProperty.SetInterpolationTypeToLinear()
= vtk.vtkVolumeRayCastCompositeFunction()
volumeMapper = vtk.vtkFixedPointVolumeRayCastMapper()
volumeMapper.SetInputConnection(reader.GetOutputPort())
volume = vtk.vtkVolume()
volume.SetMapper(volumeMapper)
volume.SetProperty(volumeProperty)
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(1500, 1500)
iren = vtkTkRenderWindowInteractor(self.root, rw=renWin, width=640, height=480)
iren.Initialize()
ren.AddVolume(volume)
ren.SetBackground(1, 1, 1)
renWin.Render()
Instantiate necessary classes and create VTK pipeline
rw = vtk.vtkRenderWindow()
rw.SetSize(1500, 1500)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.Initialize()
iren.Start()
As a newbie, I can´t upload an image.
Please help me on this topic.