[vtkusers] Trying to connect ITK - VTK - ITK

Michal Srna kositch at seznam.cz
Mon Apr 11 10:15:18 EDT 2011


Hello dear VTK users,

I would like to connect two 3D images from ITK (same dimensions) to VTK and blend them using vtkImageBlend. The problem is, that when I run the code, it crashes on this part of the code of vtkImageImport.cxx

  if (this->WholeExtentCallback)
    {
    tryCatchMacro(
      this->SetWholeExtent(
->        (this->WholeExtentCallback)(this->CallbackUserData)),
      "Calling WholeExtentCallback: ");
    }

Here is my corresponding code.  "TransformedImportFilter" and  "FixedImportFilter" are outputs of ITKImageFilter, which connects my image data from memory into the ITK pipeline:

                          /*connecting ITK to VTK*/
				typedef itk::ImageToVTKImageFilter< TransformedImageType > ITK_to_VTK_ConnectorType;

				ITK_to_VTK_ConnectorType::Pointer connector_ITK_to_VTK_alpha_data1 = ITK_to_VTK_ConnectorType::New();
				ITK_to_VTK_ConnectorType::Pointer connector_ITK_to_VTK_alpha_data2 = ITK_to_VTK_ConnectorType::New();

				connector_ITK_to_VTK_alpha_data1->SetInput( TransformedImportFilter->GetOutput() );
				connector_ITK_to_VTK_alpha_data2->SetInput( FixedImportFilter->GetOutput() );
			
			/*blending image data*/
				vtkSmartPointer<vtkImageBlend> blend = vtkSmartPointer<vtkImageBlend>::New();
				blend->SetOpacity(0, 0.5);
				blend->SetOpacity(1, 0.5);
				blend->SetInput(0,connector_ITK_to_VTK_alpha_data1->GetOutput());  
				blend->SetInput(0,connector_ITK_to_VTK_alpha_data2->GetOutput());
			
			/*connecting VTK to ITK*/
				typedef itk::VTKImageToImageFilter< TransformedImageType > VTK_to_ITK_ConnectorType;

				VTK_to_ITK_ConnectorType::Pointer connector_VTK_to_ITK = VTK_to_ITK_ConnectorType::New();

				connector_VTK_to_ITK->SetInput( blend->GetOutput() );

			/*writing the data into DICOM*/
				typedef itk::ImageFileWriter< TransformedImageType > WriterType; 
				WriterType::Pointer writer = WriterType::New();
				writer->SetFileName(output_alpha_visualization);
				writer->SetInput(connector_VTK_to_ITK->GetOutput() ); 
				writer->Update(); 

I think the problem is already in process of importing data from ITK to VTK. I am using ITKv4 and VTK 5.6.1 on Windows platform with MVSC++.

I will be happy, if someone will help me.

Best regards,

Pavli



More information about the vtkusers mailing list