[Insight-users] Problems taking a vtk dataset into itk

Luis Ibanez luis.ibanez@kitware.com
Tue, 14 Jan 2003 11:40:32 -0500


Hi John,

Please use the class

      itkVTKImageToImageFilter

available in

      Insight/Auxiliary/vtk

This class encapsulates the vtkExporter
and itkImporter that will move image
data from VTK to ITK and viceversa.

The use is quite simple:

   typedef itk::VTKImageToImageFilter<ImageType> AdaptorType;
   AdaptorType::Pointer adaptor = Adaptor::New();

   adaptor->SetInput( vtkFilter->GetOutput()  );
   itkFilter->SetInput(  adaptor->GetOutput() );


This adaptor class will take care of the
ITK-VTK pipeline connections for you.

The complementary class

    itkImageToVTKImage

will do the conversion from ITK to VTK.

Please let us know if you find any problems.


Thanks


    Luis



-----------------------
John David Fleig wrote:
> Problem:
>  I don't believe the data is getting over to the itk datatype
> 
> Code Snippet:
> 
>   //Before this part I have used a vtk TIFF Reader
>   typedef itk::Image<unsigned char,3> CharType;
>  
>   input->Print(cerr);
> 
>   //setup Exporter for itk format
>   cerr << "About to use vtkImageExport" << endl;
>   vtkImageExport *movingVtkExporter = vtkImageExport::New();
>   movingVtkExporter->SetInput(input);
>  
>   //setup itk Importer to read data
>   cerr << "About to use VTKImageImport" << endl;
>   typedef itk::VTKImageImport<CharType> ImageImportType;
>   ImageImportType::Pointer movingItkImporter = ImageImportType::New();
>     
>   //Connect vtk->itk pipe
>   cerr << "About to connect pipelines" << endl;
>   ConnectPipelines(movingVtkExporter, movingItkImporter);
>   
>   cerr << "printing pipe in middle" << endl;
>   movingItkImporter->GetOutput()->Print(cerr);
> 
> Results of first print (input)
> vtkStructuredPoints (0x80f6f00)
>   Debug: Off
>   Modified Time: 153
>   Reference Count: 1
>   Registered Events: (none)
>   Source: 0x80f6e08
>   Release Data: Off
>   Data Released: False
>   Global Release Data: Off
>   MaximumNumberOfPieces: -1
>   PipelineMTime: 136
>   UpdateTime: 151
>   UpdateExtent: Not Initialized
>   Update Number Of Pieces: 1
>   Update Piece: 0
>   Update Ghost Level: 0
>   RequestExactExtent: Off
>    UpdateExtent: 0, 1023, 0, 767, 0, 0
>   WholeExtent: 0, 1023, 0, 767, 0, 0
>   Field Data:
>     Debug: Off
>     Modified Time: 141
>     Reference Count: 1
>     Registered Events: (none)
>     Number Of Arrays: 0
>     Number Of Components: 0
>     Number Of Tuples: 0
>   Locality: 0
>   NumberOfConsumers: 0
>   ExtentTranslator: (0x80f7080)
>   MaximumNumberOfPieces: -1
>   Number Of Points: 786432
>   Number Of Cells: 784641
>   Cell Data:
>     Debug: Off
>     Modified Time: 143
>     Reference Count: 1
>     Registered Events: (none)
>     Number Of Arrays: 0
>     Number Of Components: 0
>     Number Of Tuples: 0
>     Copy Flags: ( 1 1 1 1 1 )
>     Scalars: (none)
>     Vectors: (none)
>     Normals: (none)
>     TCoords: (none)
>     Tensors: (none)
>   Point Data:
>     Debug: Off
>     Modified Time: 150
>     Reference Count: 1
>     Registered Events: (none)
>     Number Of Arrays: 1
>     Array 0 name = scalars
>     Number Of Components: 3
>     Number Of Tuples: 786432
>     Copy Flags: ( 1 1 1 1 1 )
>     Scalars: 
>       Debug: Off
>       Modified Time: 147
>       Reference Count: 1
>       Registered Events: (none)
>       Name: scalars
>       Number Of Components: 3
>       Number Of Tuples: 786432
>       Size: 2359296
>       MaxId: 2359295
>       LookupTable: (none)
>       Array: 0x42f45008
>     Vectors: (none)
>     Normals: (none)
>     TCoords: (none)
>     Tensors: (none)
>   Bounds: 
>     Xmin,Xmax: (0, 1023)
>     Ymin,Ymax: (0, 767)
>     Zmin,Zmax: (0, 0)
>   Compute Time: 0
>   Release Data: Off
>   ScalarType: 3
>   NumberOfScalarComponents: 3
>   Spacing: (1, 1, 1)
>   Origin: (0, 0, 0)
>   Dimensions: (1024, 768, 1)
>   Increments: (3, 3072, 2359296)
>   Extent: (0, 1023, 0, 767, 0, 0)
>   WholeExtent: (0, 1023, 0, 767, 0, 0)
> 
> Results of second print (itk)
> 
> Image (0x80a1ac8)
>   Reference Count: 1
>   Modified Time: 9
>   Debug: Off
>   Observers: 
>     none
>   Source: (0x80ae908) 
>   Source output index: 0
>   Release Data: Off
>   Data Released: False
>   Global Release Data: Off
>   PipelineMTime: 0
>   UpdateTime: 0
>   LastRequestedRegionWasOutsideOfTheBufferedRegion: 0
>   LargestPossibleRegion: 
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [0, 0, 0]
>   BufferedRegion: 
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [0, 0, 0]
>   RequestedRegion: 
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [0, 0, 0]
>   Origin: [0, 0, 0]
>   Spacing: [1, 1, 1]
>   PixelContainer: ImportImageContainer (0x80f8398)
>   Reference Count: 2
>   Modified Time: 4
>   Debug: Off
>   Observers: 
>     none
>   Pointer: 0x80f83c4
>   Container manages memory: true
>   Size: 0
>   Capacity: 0
> 
> 
>   IndexToPhysicalTransform: AffineTransform (0x80f83d8)
>   Reference Count: 2
>   Modified Time: 5
>   Debug: Off
>   Observers: 
>     none
>   Matrix: 
>     1 0 0 0
>     0 1 0 0
>     0 0 1 0
> 
> 
>   PhysicalToIndexTransform: AffineTransform (0x80f8698)
>   Reference Count: 2
>   Modified Time: 6
>   Debug: Off
>   Observers: 
>     none
>   Matrix: 
>     1 0 0 0
>     0 1 0 0
>     0 0 1 0
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>