[Insight-users] Problem using ITK + VTK + QT (QVTKWidget)

Luis Ibanez luis.ibanez at kitware.com
Sat Mar 21 14:02:13 EDT 2009


Hi Dirk,

Can you please try calling:

         connector->Update()

before you get its output with:

         vtkimage = connector->GetOutput();


Please let us know if you still find a segmentation fault.


     Thanks


        Luis


----------------
Dirk Boye wrote:
> Hello guys,
> 
> I got a problem using ITKtoVTK Image Filter together with QVTKWidget in QT.
> Here's my code:
> 
> ---------------------------------
> 
>           typedef itk::Image<unsigned short,2>            ImageType;
>           typedef itk::ImageFileReader<ImageType>         ReaderType;
>           typedef itk::ImageToVTKImageFilter<ImageType>   ConnectorType;
> 
>           ReaderType::Pointer reader = ReaderType::New();
>           ConnectorType::Pointer connector = ConnectorType::New();
> 
>           std::string filename = ui.lineEdit_file->text().toStdString();
>           vtkDICOMImageReader *reader2=vtkDICOMImageReader::New();
> 
>           reader->SetFileName( filename.c_str() );
>           connector->SetInput( reader->GetOutput() );
> 
>           reader2->SetFileName( filename.c_str() );
> 
> 
>           vtkImageData* vtkimage = vtkImageData::New();
>           vtkimage=reader2->GetOutput();   // Uses VTK Classes to read
> DICOM file
> //Problem vtkimage=connector->GetOutput();  // Uses ITK -> VTK Filter
> 
>           vtkImageViewer* viewer = vtkImageViewer::New();
>           viewer->SetInput( vtkimage );
>           ui.qvtkWidget->SetRenderWindow(viewer->GetRenderWindow());
>           viewer->SetupInteractor(ui.qvtkWidget->GetRenderWindow()->GetInteractor());
>           viewer->Render();
>           viewer->SetColorWindow( 254 );
>           viewer->SetColorLevel( 128 );
> 
> --------------------------------------
> 
> In this example I use "vtkimage=reader2->GetOutput()".
> "reader2" is using vtkDICOMImageReader. That works just fine. I can
> adjust contrast etc. by using my mouse in the QVTKWidget.
> 
> When i change that "vtkimage=..." to "vtkmage=connector->GetOutput()"
> I get an Segmentation Fault as soon as i click on my button to load
> the DICOM file.
> 
> Any suggestions? I really don't understand why I get that segmentation
> fault. Both "connector->GetOutput()" and "reader2->GetOutput()" give a
> vtkImageData.
> 
> Somebody had a similar problem here:
> http://marc.info/?l=vtkusers&m=121225544421713&w=2
> But overriding all mouse event handlers didn't work for me.
> 
> Thanks for your help!
> 
> Greetings from sunny Villigen (Switzerland)
> Dirk Boye
> _____________________________________
> 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 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 Insight-users mailing list