[Insight-users] Problems taking a vtk dataset into itk
John David Fleig
fleig@bmi.osu.edu
Wed, 15 Jan 2003 12:01:49 -0500 (EST)
We updated our copy of itk through cvs here and I tried the following
code:
typedef itk::Image<unsigned char,2> CharType;
vtkTIFFReader* imageReader = vtkTIFFReader::New();
imageReader->SetFileName("Wrath.tif");
imageReader->Update();
imageReader->Print(cerr);
cerr << "About to run itk::VTKImageToImageFilter" << endl;
typedef itk::VTKImageToImageFilter<CharType> ImporterToITK;
ImporterToITK::Pointer movingItkImporter = ImporterToITK::New();
movingItkImporter->SetInput(imageReader->GetOutput());
movingItkImporter->Update();
cerr << "printing pipe in middle" << endl;
movingItkImporter->GetOutput()->Print(cerr);
cerr << "About to run itk::ImageToVTKImageFilter" << endl;
typedef itk::ImageToVTKImageFilter<CharType> ImporterToVTK;
ImporterToVTK::Pointer vtkimporter = ImporterToVTK::New();
vtkimporter->SetInput( movingItkImporter->GetOutput() );
vtkimporter->Update();
cerr << "About to run vtkImageCast" << endl;
vtkImageCast *caster = vtkImageCast::New();
caster->SetInput( vtkimporter->GetOutput() );
caster->SetOutputScalarTypeToUnsignedChar();
cerr << "update" << endl;
caster->Update();
cerr << "writing image" << endl;
vtkTIFFWriter* imageWriter = vtkTIFFWriter::New();
imageWriter->SetInput(caster->GetOutput());
imageWriter->SetFileName("Wrath_copy.tif");
imageWriter->Write();
What I get out is a dump of imageReader which looks fine.
the dump of the movingItkImporter still looks a little funny to me, but
the big thing is that it will print me "update" message, but it will not
get to the "writing image" part.
I still might be missing something easy and fundamental about how these
things work with each other, but I don't know.
David
On Tue, 14 Jan 2003, Luis Ibanez wrote:
> 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.
>