[Insight-users] Problem using ImageToVTKImageFilter and QVTKWidget

Françoise Lefebvre lefebvre at imnc.in2p3.fr
Mon Oct 5 11:09:44 EDT 2009


Hello,

I got a problem using ImageToVTKImageFilter together with QVTKWidget in QT.

I am using Qt4.4.3, vtk5.4, itk3.14, msvc2008.


Here's part ok my code:

typedef itk::Image<unsigned short,2>            ImageType;
typedef itk::ImageFileReader<ImageType>         ReaderType;
typedef itk::ImageToVTKImageFilter<ImageType>   ConnectorType;

vtkPNGReader* readerVTK = vtkPNGReader::New();
readerVTK->SetFileName("file.png");

ReaderType::Pointer readerITK = ReaderType::New();
readerITK->SetFileName("file.png");
ConnectorType::Pointer connector = ConnectorType::New();
connector->SetInput( readerITK->GetOutput() );

vtkImageData* vtkimage = vtkImageData::New();
// Uses VTK Classes to read -> OK
vtkimage = readerVTK->GetOutput();
// Uses ITK_VTK Connector -> segmentation fault
vtkimage = connector->GetOutput();

vtkImageViewer* viewer = vtkImageViewer::New();
viewer->SetInput(vtkimage );
qvtkWidget->SetRenderWindow(viewer->GetRenderWindow());

viewer->SetupInteractor(qvtkWidget->GetRenderWindow()->GetInteractor());
viewer->Render();
viewer->SetColorWindow( 254 );
viewer->SetColorLevel( 128 );



Using QVTKWidget and a vtkReader (vtkPNGReader in my case) works fine 
but using QVTKWidget  and an ImageToVTKImageFilter connector makes the 
program crash in the paintEvent.

When turning on the setAutomaticImageCacheEnabled to true, the program 
crashes in the paintEvent when the window is resized (size increased).

Thanks for your help


Françoise LEFEBVRE










More information about the Insight-users mailing list