[vtkusers] AppendImagecomponents with output of ImageToVTKImageFilter ITK does not work

j-P cervellone at gmail.com
Wed Jul 11 09:08:46 EDT 2012


Hello

I am fairly new to ITK and Vtk.
I am trying to read a stack of 2d images into one volume in itk processthem
and pass them to vtk and append them into one structure to render them. The
problem is that ImageToVTK outputs vtkImageData and the append components
filter expects vtkdataObject. 
I tried safecasting it to vtkDataobject but that does not work. The mapper
always crashes, and inside the append object there are no components at all. 

Can somebody help string these two modules together ? 

here is the code i Use:

append = vtk.vtkImageAppendComponents()
chanReader = itk.ImageSeriesReader.IUS3.New()


for chan in channels : 

    names = GetfileNames(chan)
    #print names
    
    chanReader.SetFileNames(names.GetFileNames())
    print "chanReader.GetOutput()"
    print chanReader.GetOutput()
    SpacingSetVolume = itk.ChangeInformationImageFilter.IUS3.New()
    SpacingSetVolume.SetInput(chanReader.GetOutput())
    SpacingSetVolume.ChangeSpacingOn() # !!!!!!!!!!!!!!!
    SpacingSetVolume.SetOutputSpacing(spacing)
    SpacingSetVolume.Update()
    
    
    Itk2Vtk = ItkVtkGlue.ImageToVTKImageFilter.IUS3.New()
    print "SpacingSetVolume.GetOutput()"
    print SpacingSetVolume.GetOutput()
    Itk2Vtk.SetInput(SpacingSetVolume.GetOutput())
    Itk2Vtk.UpdateOutputInformation()
    Itk2Vtk.Update()
    
    #cast = Itk2Vtk.GetOutput()
    #cast.SafeDownCast(cast)
    cast = vtk.vtkDataObject.SafeDownCast(Itk2Vtk.GetOutput())
    
    if chan == "red":
       
        append.SetInput(cast)
       
    else:
        append.AddInput(cast)
    
    #mapper 

mapper = vtk.vtkFixedPointVolumeRayCastMapper() #always look w which mappser
suits best
mapper.SetInput(append.GetOutput())
mapper.Update()
print "did not crash Weee"


--
View this message in context: http://vtk.1045678.n5.nabble.com/AppendImagecomponents-with-output-of-ImageToVTKImageFilter-ITK-does-not-work-tp5714637.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list