[vtkusers] Multiple Actore Dicom Image from Itk
stefano serviddio
s.serviddio at gmail.com
Mon Sep 28 18:04:24 EDT 2015
Hi,
I would like to watch on my screen three dicom image that I read from ITK
reader, then I'm trying to write this code, What do you think about it?
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkGDCMImageIO.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkVersion.h"
#include "vtkImageViewer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkImageActor.h"
#include "vtkImageMapper3D.h"
#include "vtkInteractorStyleImage.h"
#include "vtkRenderer.h"
#include "vtkCamera.h"
using namespace std;
using namespace itk;
int main( )
{
const unsigned int Dimension = 2;
typedef unsigned short PixelType;
typedef float InternalPixelType;
typedef signed short OutputPixelType;
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> ConnectorType1;
ConnectorType1::Pointer originalConnector1 = ConnectorType1::New();
typedef itk::ImageToVTKImageFilter<MovingImageType> ConnectorType2;
ConnectorType2::Pointer originalConnector2 = ConnectorType2::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);
//Read Dicom Image
fixedImageReader->Update();
movingImageReader->Update();
FixedImageType::Pointer Image1=fixedImageReader->GetOutput();
MovingImageType::Pointer Image2=movingImageReader->GetOutput();
originalConnector1->SetInput(Image1);
originalConnector2->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);
renderer1->AddActor(originalActor2);
renderer1->ResetCamera();
renderer1->GetActiveCamera();
vtkSmartPointer<vtkRenderWindow> renderWindow1 =
vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor1 =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkInteractorStyleImage> style =
vtkSmartPointer<vtkInteractorStyleImage>::New();
renderer1->SetBackground(1,1,1);
renderWindow1->AddRenderer(renderer1);
renderWindow1->Render();
renderWindowInteractor1->SetInteractorStyle(style);
renderWindowInteractor1->SetRenderWindow(renderWindow1);
renderWindowInteractor1->Initialize();
renderWindowInteractor1->Start();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150929/9013a147/attachment.html>
More information about the vtkusers
mailing list