[vtkusers] problem with convert itk to vtk
Роман Глуховский
roman_glu at mail.ru
Fri Apr 25 08:52:20 EDT 2014
Hi vtkusers,
i load a DICOM-file with itk and after that i would like to display the file with vtk.
If I compile the programm I have no error. When i start the programm, its crashed and
i get a return value "0".
In the debug-mode i get a "segmentation fault" and the programm stops at this position
----------> m_Importer->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback());
in the "itkImageToVTKImageFilter_hxx".
Here is my code:
typedef itk::Image<unsigned char, 3> VisualizingImageType;
typedef itk::ImageFileReader< VisualizingImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( "DICOM-File" );
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
reader->SetImageIO( gdcmImageIO );
reader->Update();
reader->GetOutput()->Print(std::cout);
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer<vtkRenderer>::New();
ren1->SetBackground(0.5f,0.5f,1.0f);
renWin->AddRenderer(ren1);
renWin->SetSize(1280,1024);
vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
renWin->Render(); // make sure we have an OpenGL context.
typedef itk::ImageToVTKImageFilter<VisualizingImageType> itkVtkConverter;
itkVtkConverter::Pointer conv=itkVtkConverter::New();
conv->GetExporter()->SetInput(reader->GetOutput());
conv->GetImporter()->Update();
conv->GetImporter()->GetOutput()->Print(std::cout);
vtkImageViewer * viewer =vtkImageViewer::New();
vtkRenderWindowInteractor * renderWindowInteractor =
vtkRenderWindowInteractor::New();
viewer->SetupInteractor( renderWindowInteractor );
viewer->SetInputData( conv->GetImporter()->GetOutput() );
viewer->SetZSlice( 0 ); // <-- Slice selection
viewer->Render();
renderWindowInteractor->Start();
viewer->Delete();
renderWindowInteractor->Delete();
conv->GetImporter()->Delete();
Thank you for your help
Roman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140425/389fd95c/attachment.html>
More information about the vtkusers
mailing list