[Insight-users] ITK to VTK image

Rick Frank rickf at fullspectrumsw.com
Fri Nov 11 22:22:49 EST 2011


I am having a strange problem after converting a DICOM image from
ITK-VTK.
 Below is my code.

const    unsigned int    Dimension = 3;
typedef  short           PixelType;
typedef itk::Image< PixelType, Dimension >  ITKImageType;

typedef itk::ImageSeriesReader< ITKImageType > ImageReaderType;

typedef itk::GDCMImageIO ImageIOType;
typedef itk::GDCMSeriesFileNames InputNamesGeneratorType;
typedef itk::NumericSeriesFileNames OutputNamesGeneratorType;
 ImageReaderType::Pointer  imageReader  = ImageReaderType::New();
 
ImageIOType::Pointer gdcmIO = ImageIOType::New();
InputNamesGeneratorType::Pointer inputNames =
InputNamesGeneratorType::New();
inputNames ->SetInputDirectory(path);
	
const ImageReaderType::FileNamesContainer & inputFileNames = inputNames
->GetInputFileNames();
 
   imageReader->SetImageIO( gdcmIO );
   imageReader->SetFileNames(inputFileNames);
   imageReader->Update();
   itk::ImageToVTKImageFilter<FixedImageType>::Pointer imageFilter =
itk::ImageToVTKImageFilter<FixedImageType>::New();
  
   imageFilter->SetInput(imageReader->GetOutput());

   imageFilter->Update();

  vtkImageData *outImage = imageFilter->GetOutput();

*******At this point the image seems to be ok *************

A little later when I pass the image into
vtkImageMapToWindowLevelColors:: SetInputConnection()
 it seems to just ignore it. I'm using DLLs so it's hard to trace into
the code -


this->WindowLevel = vtkImageMapToWindowLevelColors::New();
this->WindowLevel->SetInputConnection(image->GetProducerPort());

I get the following error
ERROR: In
C:\Projects\Civco\AccuLoc-InView\trunk\vtk-5.8.0\Filtering\vtkDemandDriv
enPipeline.cxx, line 802
vtkStreamingDemandDrivenPipeline (10AA6B78): Input for connection index
0 on input port index 0 for algorithm
vtkImageMapToWindowLevelColors(0BF63040


if I call
this->WindowLevel->GetInput() right after SetInputConnection
WindowLevel->GetInput() returns null.

I would think a debug assert or something would fire if the
SetInputConnection() failed?

Does this look familiar? Is there a better way to bring in an image from
ITK to VTK?


Thanks

Rick



More information about the Insight-users mailing list