[Insight-users] . Re: ITK to VTK image - Executive/Pipeline problem?

Rick Frank rickf at fullspectrumsw.com
Mon Nov 14 18:35:22 EST 2011


Thanks, I have more debugging information if anyone can lend a hand with
this...
When I finish converting the ITK image to VTK, the code looks like

itk::SmartPointer<itk::ImageToVTKImageFilter<FixedImageType> >
imageFilter = itk::ImageToVTKImageFilter<FixedImageType>::New();
  
   imageFilter->SetInput(imageReader->GetOutput());

   imageFilter->Update();

   * outImage= imageFilter->GetOutput();
........................
This "out" image is passed back to the caller as a pointer to a pointer:
........................
vtkImageData **outImage
........................

I then call WindowLevel->SetInput(image)

Where image is the outImage (a vtkImageData*) and WindowLevel is a
vtkImageMapToWindowLevelColors* .

Tracing into WindowLevel->SetInput() it ends up in

void vtkImageAlgorithm::SetInput(int index, vtkDataObject* input)
{
  if(input)
    {
    this->SetInputConnection(index, input->GetProducerPort());
    }.........

........................
Notice that the input (my image) is called to get its ProducerPort,
which is ends up in
........................
vtkAlgorithmOutput* vtkExecutive::GetProducerPort(vtkDataObject* d)
{
  if(this->Algorithm && d)
    {
    vtkInformation* info = d->GetPipelineInformation();
    vtkExecutive* dExecutive;
    int port;
    vtkExecutive::PRODUCER()->Get(info,dExecutive,port);
    if(dExecutive == this)
      {
      return this->Algorithm->GetOutputPort(port);
      }
    }
  return 0;
}

And dExecutive is of type  vtkImageImportExecutive.

But my image import is done, and so this executive is stale?

What should it be? My newly imported image should be somehow
disconnected from the import pipeline, I would think.... But I'm not
sure how...

Thanks for any assistance.

Rick

Date: Mon, 14 Nov 2011 10:59:46 +0100
From: D?enan Zuki? <dzenanz at gmail.com>
Subject: Re: [Insight-users] ITK to VTK image
To: Rick Frank <rickf at fullspectrumsw.com>
Cc: insight-users at itk.org
Message-ID:
	
<CAPf2UMQtPPvsZnTqnFg+9d+TvUeRQFPPAU731W2w7SzBVim-mQ at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Take a look at this example:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/VolumeRendering/itkVtkImageConv
ert

HTH

On Sat, Nov 12, 2011 at 04:22, Rick Frank <rickf at fullspectrumsw.com>
wrote:

>
> 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\vtkDemandDr
> iv
> 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