[Insight-users] how to show 3D images with itk and vtk???

杜建军 dujj at emails.bjut.edu.cn
Thu Feb 3 06:53:22 EST 2005


hi,everybody
   now, i want to read a series of images with itk reader, then make a bridge to
vtk, finally show it in mfc frame.but i get no result, please someone help me!!!
   a procedure as follows:

 typedef unsigned char                       PixelType;
 const unsigned int Dimension = 3;
 
 typedef itk::Image< PixelType, Dimension >  ImageType;
 typedef itk::ImageSeriesReader< ImageType >  ReaderType;
 typedef itk::ImageFileWriter< ImageType >  WriterType;
 
 ReaderType::Pointer seriesReader = ReaderType::New();
 WriterType::Pointer seriesWriter = WriterType::New();
 
 typedef itk::ImageToVTKImageFilter< ImageType > ConnectorFilterType;
 ConnectorFilterType::Pointer connector = ConnectorFilterType::New();
 
 const unsigned int first = 1;
 const unsigned int last  = 20;
 
 typedef itk::NumericSeriesFileNames    NameGeneratorType;
 
 NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
 
 nameGenerator->SetStartIndex( first );
 nameGenerator->SetEndIndex( last );
 nameGenerator->SetIncrementIndex( 1 );
 
 nameGenerator->SetSeriesFormat( "heart-rgb%04d.png" );
 seriesReader->SetImageIO( itk::PNGImageIO::New() );
 
seriesReader->SetFileNames( nameGenerator->GetFileNames()  );
 
 vtkImageData *m_vtk3DImageData;
 try
 { 
  connector->GetExporter()->SetInput( seriesReader->GetOutput() );
  
  m_vtk3DImageData = connector->GetImporter()->GetOutput() ;
  
  m_bShow3DData = TRUE;
 }
 catch( itk::ExceptionObject & excp )
 {
  std::cerr << "Error reading the series " << std::endl;
  std::cerr << excp.GetDescription() << std::endl;
 }

in OnDraw method, add vtk show proper functions.  
are there any errors???





More information about the Insight-users mailing list