[vtkusers] vtk 3d volume rendering -.dcm files

Hpatel hinesh_88 at hotmail.co.uk
Wed Apr 27 07:24:53 EDT 2016


Hi all,
I am new to vtk.
I am currently working on a university project and would be extremely
grateful if anyone can provide me with some advice and help. 
My setup is Pydev installed on eclipse and running vtk version 5.10.1
 I have been trying to load in a .dcm file (Ct scans) and use a 3d Volume
rendering (ray casting –isosurface function).
I previously tried using the marching cubes algorithm however the output was
very “blocky” and smoothing is not an option. 
Below is what I have tried, however I keep getting an error.  Now I’m not
entirely sure what each error means and when I google it I very easily find
myself entering an endless maze.

In short I want to take a .dcm file and 3d render the file to display a 3d
image. 
import vtk

dicompath = raw_input(“Dicom path: ”)
reader = vtk.vtkDICOMImageReader()
reader.SetDirectoryName(dicompath)
reader.Update()


t = vtk.vtkImageThreshold()
t.SetInputConnection(reader.GetOutputPort())
t.ThresholdByLower(400)
t.ReplaceInOn()
t.SetInValue(0)
t.ReplaceInOn()
t.SetOutValue(1)
t.Update()


func = vtk.vtkVolumeRayCastIsosurfaceFunction()
funcmapper = vtk.vtkVolumeRayCastMapper()
funcmapper.SetInputConnection(t.GetOutputPort())
funcmapper.SetVolumeRayCastFunction(func)

actor = vtk.vtkImageActor()
actor.SetMapper(funcmapper)

render = vtk.vtkRenderer()
render.AddActor(actor)
renderWin = vtk.vtkRenderWindow()
renderWin.AddRenderer(render)
renderWin.setSize(300,300)

rwi = vtk.vtkRenderWindowInteractor()
rwi.Initialize()
rwi.Start()
 
Thanks in advance.




--
View this message in context: http://vtk.1045678.n5.nabble.com/vtk-3d-volume-rendering-dcm-files-tp5737898.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list