[ITK] [ITK-users] Fwd: problem with convert itk to vtk

Роман Глуховский roman_glu at mail.ru
Tue Apr 29 04:45:21 EDT 2014


I change the part of my programm to load the ImageSeries,

    typedef itk::Image<unsigned char, 3> ImageType;
    typedef itk::ImageSeriesReader< ImageType >  ReaderType;
    ReaderType::Pointer reader = ReaderType::New();
    typedef itk::GDCMImageIO ImageIOType;
    ImageIOType::Pointer dicomIO = ImageIOType::New();
    reader->SetImageIO(dicomIO);

    typedef itk::GDCMSeriesFileNames NamesGeneratorType;
    NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
    nameGenerator->SetDirectory("Folder");


    // get series IDs
    typedef std::vector<std::string> SeriesIdContainer;
    const SeriesIdContainer &seriesUID = nameGenerator->GetSeriesUIDs();

    // get dicom series
    typedef std::vector<std::string> FileNamesContainer;
    FileNamesContainer fileName;
    fileName=nameGenerator->GetFileNames(seriesUID.begin()->c_str());
    reader->SetFileNames(fileName);

    // pull reader
    reader->Update();

But my programm crash again at the same position, when i try to convert to vtk.


Sat, 26 Apr 2014 07:12:55 +0800 (CST) от 关红彦 <ghy at tellyes.com>:
>
>
>I just wonder if your 3D medical images save as a file or a series of images.
>If you save  them to a series of files,  you shouldn't  do this: 
>  #include < itkImageFileReader.h >
>reader->SetFileName( "DICOM-File" );   
>
>but this:
>#include < itkImageSeriesReader.h >  
>void  SetFileNames  (const  FileNamesContainer  &name)
>This class can read a series of *.DCM files that are using a lot in the hospital.
>
>
>At 2014-04-25 20:52:20,"Роман Глуховский" <roman_glu at mail.ru> wrote:
>>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

_______________________________________________
Powered by  www.kitware.com

Visit other Kitware open-source projects at  http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at:  http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


----------------------------------------------------------------------

----------------------------------------------------------------------

-- 
Роман Глуховский
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140429/e4c21976/attachment-0001.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list