[Insight-users] read DICOM
Massinissa Bandou
Massinissa.Bandou at USherbrooke.ca
Sun Apr 28 23:47:09 EDT 2013
Hello ITK,
I'm trying to read a dicom file and display it on VTK. I have the following
image S_00032.dcm
<http://itk-users.7.n7.nabble.com/file/n31289/S_00032.dcm> but I can't see
anything. I have to set a map color on vtk to adjust the pixel intensity
values. Is there anything that I have to do to display the dicom file in the
right grey scale?
Here is my code:
typedef float PixelType;
typedef itk::Image<PixelType,2> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer imageReader = ReaderType::New();
imageReader->SetFileName(file.toStdString().c_str());
imageReader->Update();
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
imageReader->SetImageIO(gdcmImageIO);
imageReader->Update();
ImageType::Pointer image = imageReader->GetOutput();
typedef itk::ImageToVTKImageFilter<ImageType>ConnectorType;
ConnectorType::Pointer connector = ConnectorType::New();
connector->SetInput(image);
vtkSmartPointer<vtkImageViewer2> imageViewer =
vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInput(connector->GetOutput());
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
imageViewer->SetupInteractor(interactor);
interactor->Initialize();
imageViewer->Render();
interactor->Start();
Thank you for your help!!
Massi
--
View this message in context: http://itk-users.7.n7.nabble.com/read-DICOM-tp31289.html
Sent from the ITK - Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list