[ITK-users] VTk image Screen

stefano serviddio s.serviddio at gmail.com
Mon Sep 28 12:37:45 EDT 2015


Hi,
It's possible to visualize three  images in the same window with VTK ,
after load them by itk reader.
I try this code but I visulize only an image:

const unsigned int Dimension = 2;
  typedef double PixelType;

  typedef Image< PixelType, Dimension >  FixedImageType;
  typedef Image< PixelType, Dimension >  MovingImageType;



  typedef ImageFileReader< FixedImageType  > FixedImageReaderType;
  typedef ImageFileReader< MovingImageType > MovingImageReaderType;
  typedef GDCMImageIO GDCMType;
  GDCMType::Pointer gdcm=GDCMType::New();
  FixedImageReaderType::Pointer fixedImageReader   =
FixedImageReaderType::New();
  MovingImageReaderType::Pointer movingImageReader =
MovingImageReaderType::New();



   typedef itk::ImageToVTKImageFilter<FixedImageType> ConnectorType;
  ConnectorType::Pointer originalConnector1 = ConnectorType::New();
  ConnectorType::Pointer originalConnector2 = ConnectorType::New();


  char* filename1="D:/Images/def00001.dcm";
  char* filename2="D:/Images/def100001.dcm";
  fixedImageReader->SetFileName( filename1 );
    movingImageReader->SetFileName( filename2 );
  fixedImageReader->SetImageIO(gdcm);
  movingImageReader->SetImageIO(gdcm);

  resultfile<<filename1<<std::endl;
  resultfile<<filename2<<std::endl;

  fixedImageReader->Update();
  movingImageReader->Update();



  FixedImageType::Pointer Image1=fixedImageReader->GetOutput();
  MovingImageType::Pointer Image2=movingImageReader->GetOutput();


  originalConnector1->SetInput(Image1);
  originalConnector1->SetInput(Image2);


  vtkSmartPointer<vtkImageActor> originalActor1 =
 vtkSmartPointer<vtkImageActor>::New();
  vtkSmartPointer<vtkImageActor> originalActor2 =
 vtkSmartPointer<vtkImageActor>::New();

  originalConnector1->Update();
  originalConnector2->Update();



originalActor1->GetMapper()->SetInputData(originalConnector1->GetOutput());

originalActor2->GetMapper()->SetInputData(originalConnector2->GetOutput());


  vtkSmartPointer<vtkRenderer> renderer1 =
vtkSmartPointer<vtkRenderer>::New();

  renderer1->AddActor(originalActor1);
  //enderer1->AddActor(originalActor2);
  renderer1->ResetCamera();



  vtkSmartPointer<vtkRenderWindow> renderWindow1 =
vtkSmartPointer<vtkRenderWindow>::New();
    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor1 =
vtkSmartPointer<vtkRenderWindowInteractor>::New();

  vtkSmartPointer<vtkInteractorStyleImage> style =
vtkSmartPointer<vtkInteractorStyleImage>::New();



  renderWindow1->AddRenderer(renderer1);
  renderWindowInteractor1->SetInteractorStyle(style);


  renderWindowInteractor1->SetRenderWindow(renderWindow1);

  renderWindowInteractor1->Initialize();


  renderWindowInteractor1->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150928/eabeaafd/attachment.html>


More information about the Insight-users mailing list