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

Роман Глуховский roman_glu at mail.ru
Thu May 8 11:02:48 EDT 2014


 Thank you for your help, now with CMakeLists.txt it works. 

I have one question more:
Is it possible to save loaded DICOM-Series (after a thresholdfilter for example) to a SQLDatabase
and load it from the database again?

Thu, 8 May 2014 10:57:24 +0200 от Dženan Zukić <dzenanz at gmail.com>:
>Below code runs without problems on my system (the last delete() was crashing it after closing). Screenshot is attached. Dataset in question is here:
>http://www.cg.informatik.uni-siegen.de/data/Downloads/DzZ.zip
>
>Problem with your .pro file is lack of itkImageToVTKImageFilter in either include path or libs. With such a simple "project" you can easily switch to  CMake .
>
>#include <itkImageFileReader.h>
>#include <itkGDCMImageIO.h>
>#include <vtkSmartPointer.h>
>#include <vtkRenderWindow.h>
>#include <vtkRenderer.h>
>#include <vtkRenderWindowInteractor.h>
>#include <itkImageToVTKImageFilter.h>
>#include <vtkImageViewer.h>
>#include <itkImageSeriesReader.h>
>#include <itkGDCMSeriesFileNames.h>
>
>void main()
>{
>    typedef itk::Image<unsigned char, 3> VisualizingImageType;
>    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("D:/Repo/Data/Zukic/DzZ_1189252");
>
>
>    // 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();
>    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(); //causes error due to unnecessary Delete
>}
>
>
>
>On Thu, May 8, 2014 at 10:19 AM, Роман Глуховский  < roman_glu at mail.ru > wrote:
>>Hi,
>>
>>I build the libraries agian. the examples works now. 
>>
>>But i get the same error again in my programm. 
>>
>>
>>Here is my pro-file, maybe here is something wrong:
>>
>>#-------------------------------------------------
>>#
>># Project created by QtCreator 2014-05-07T17:08:03
>>#
>>#-------------------------------------------------
>>
>>QT       += core gui
>>
>>greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
>>
>>TARGET = test
>>TEMPLATE = app
>>
>>INCLUDEPATH+= /usr/local/include/ITK-4.5\
>>/usr/local/include/vtk-6.1
>>DEPENDPATH+=/usr/local/include/ITK-4.5\
>>/usr/local/include/vtk-6.1
>>LIBS += -L/usr/local/lib/\
>>#-lITKBiasCorrection-4.5\
>>-lITKBioCell-4.5\
>>-lITKCommon-4.5\
>>-lITKDICOMParser-4.5\
>>-litkdouble-conversion-4.5\
>>-lITKEXPAT-4.5\
>>-ITKFEM-4.5\
>>-litkgdcmCommon-4.5\
>>-litkgdcmDICT-4.5\
>>-litkgdcmDSED-4.5\
>>-litkgdcmIOD-4.5\
>>-litkgdcmjpeg8-4.5\
>>-litkgdcmjpeg12-4.5\
>>-litkgdcmjpeg16-4.5\
>>-litkgdcmMSFF-4.5\
>>-litkgdcmuuid-4.5\
>>-lITKgiftiio-4.5\
>>-litkhdf5_cpp-4.5\
>>-litkhdf5-4.5\
>>-lITKIOBioRad-4.5\
>>-lITKIOBMP-4.5\
>>-lITKIOCSV-4.5\
>>-lITKIOGDCM-4.5\
>>-lITKIOGE-4.5\
>>-lITKIOGIPL-4.5\
>>-lITKIOHDF5-4.5\
>>-lITKIOImageBase-4.5\
>>-lITKIOIPL-4.5\
>>-lITKIOJPEG-4.5\
>>-lITKIOLSM-4.5\
>>-lITKIOMesh-4.5\
>>-lITKIOMeta-4.5\
>>-lITKIONIFTI-4.5\
>>-lITKIONRRD-4.5\
>>-lITKIOPNG-4.5\
>>-lITKIOSiemens-4.5\
>>-lITKIOSpatialObjects-4.5\
>>-lITKIOStimulate-4.5\
>>-lITKIOTIFF-4.5\
>>-lITKIOTransformBase-4.5\
>>-lITKIOTransformHDF5-4.5\
>>-lITKIOTransformInsightLegacy-4.5\
>>-lITKIOTransformMatlab-4.5\
>>-lITKIOVTK-4.5\
>>-lITKIOXML-4.5\
>>-litkjpeg-4.5\
>>-lITKKLMRegionGrowing-4.5\
>>-lITKLabelMap-4.5\
>>-lITKMesh-4.5\
>>-lITKMetaIO-4.5\
>>-litkNetlibSlatec-4.5\
>>-lITKniftiio-4.5\
>>-lITKNrrdIO-4.5\
>>-litkopenjpeg-4.5\
>>-lITKOptimizers-4.5\
>>#-lITKOptimizersv4-4.5\
>>-lITKPath-4.5\
>>-litkpng-4.5\
>>-lITKPolynomials-4.5\
>>-lITKQuadEdgeMesh-4.5\
>>#-lITKReview-4.5\
>>-lITKSpatialObjects-4.5\
>>-lITKStatistics-4.5\
>>-litksys-4.5\
>>-litktiff-4.5\
>>-litkv3p_lsqr-4.5\
>>-litkv3p_netlib-4.5\
>>-litkvcl-4.5\
>>-lITKVideoCore-4.5\
>>-lITKVideoIO-4.5\
>>-litkvnl_algo-4.5\
>>-litkvnl-4.5\
>>-lITKVNLInstantiation-4.5\
>>-lITKVTK-4.5\
>>-lITKWatersheds-4.5\
>>-litkzlib-4.5\
>>-lITKznz-4.5\
>>#-lvtkIOLSDyna
>> 
>>LIBS += -L/usr/local/lib/vtk-6.1/\
>>#-lMapReduceMPI\
>>#-lmpistubs-6.1\
>>-lQVTK\
>>-lvtkalglib\
>>-lvtkCharts\
>>-lvtkCommon\
>>-lvtkDICOMParser\
>>-lvtkexoIIc\
>>-lvtkexpat-6.1\
>>-lvtkFiltering\
>>-lvtkfreetype-6.1\
>>-lvtkftgl\
>>-lvtkGenericFiltering\
>>-lvtkGeovis\
>>-lvtkGraphics\
>>-lvtkhdf5_hl-6.1\
>>-lvtkhdf5-6.1\
>>-lvtkHybrid\
>>-lvtkImaging\
>>-lvtkInfovis\
>>-lvtkIO\
>>-lvtkjpeg-6.1\
>>-lvtklibxml2-6.1\
>>-lvtkmetaio\
>>-lvtkNetCDF_cxx-6.1\
>>-lvtkNetCDF-6.1\
>>-lvtkpng-6.1\
>>-lvtkproj4\
>>-lvtkRendering\
>>-lvtksqlite-6.1\
>>-lvtksys\
>>-lvtktiff-6.1\
>>-lvtkverdict\
>>-lvtkViews\
>>-lvtkVolumeRendering\
>>-lvtkWidgets\
>>-lvtkzlib-6.1
>>
>>SOURCES += main.cpp\
>>        mainwindow.cpp
>>
>>HEADERS  += mainwindow.h
>>
>>FORMS    += mainwindow.ui.
>>
>>
>>
>>Tue, 29 Apr 2014 13:48:33 +0200 от Dženan Zukić < dzenanz at gmail.com >:
>>
>>>You could try that, definitely. Using static libraries instead of dynamic can save you some headaches.
>>>
>>>
>>>On Tue, Apr 29, 2014 at 1:45 PM, Роман Глуховский  < roman_glu at mail.ru > wrote:
>>>>it could be that i have some problems with the libraries.
>>>>
>>>>should i compile and build ITK and VTK again?
>>>>
>>>>
>>>>
>>>>Tue, 29 Apr 2014 13:14:29 +0200 от Dženan Zukić < dzenanz at gmail.com >:
>>>>
>>>>>Then you most likely have some problems with how libraries are compiled/built. Can you successfully run examples that come with ITK and VTK libraries? If not, you first need to take care of those issues.
>>>>>
>>>>>
>>>>>On Tue, Apr 29, 2014 at 1:01 PM, Роман Глуховский  < roman_glu at mail.ru > wrote:
>>>>>>I try this example, but i get also a segmentation fault
>>>>>>
>>>>>>
>>>>>>Tue, 29 Apr 2014 12:04:45 +0200 от Dženan Zukić < dzenanz at gmail.com >:
>>>>>>
>>>>>>>Have you seen this example?
>>>>>>>http://vtk.org/Wiki/VTK/ExamplesBoneYard/Cxx/VolumeRendering/itkVtkImageConvert
>>>>>>>
>>>>>>>
>>>>>>>On Tue, Apr 29, 2014 at 10:45 AM, Роман Глуховский  < roman_glu at mail.ru > wrote:
>>>>>>>>
>>>>>>>>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
>>>>>>>>
>>>>>>>>
>>>>>>>>----------------------------------------------------------------------
>>>>>>>>
>>>>>>>>----------------------------------------------------------------------
>>>>>>>>
>>>>>>>>-- 
>>>>>>>>Роман Глуховский
>>>>>>>>
>>>>>>>>_____________________________________
>>>>>>>>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
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20140508/bad2d58e/attachment.html>


More information about the Insight-users mailing list