[vtkusers] Problem about vtkImageViewer2 when using itk+vtk+Qt

Bryn Lloyd blloyd at vision.ee.ethz.ch
Fri May 29 11:37:58 EDT 2009


This is not answering your question, but maybe it is of interest:

I have written a small extension to vtkImageViewer2, which has keyboard 
observers to change between slices of the 3D image.

Additionally, I have added the functionality to select seed points by 
clicking on the image (much like ImageViewer in ITK-Applications). This 
is very useful, e.g. in segmentation algorithms.

Finally, I use the vtkKWImageIO and vtkKWImage classes from the Insight 
Journal, which interface ITK in quite a nice way, so I can load all ITK 
readable images and directly connect the output to the viewer.

Have a look here:
http://people.ee.ethz.ch/~blloyd/ImageViewer/

An example application is: test-ImageViewer.cxx

The usage (keys to change slices/select points etc.) is described a bit 
in the header file: ImageViewer.h

Cheers
Bryn





iconme wrote:
> Dear all:
>   I'm now using QT+ITK+VTK combination. I loaded a 3D image of analyze 
> format using itk and change it to vtk image, and I'd like to show the 
> slices in a qvtkWidget by vtkImageViewer2. The pipeline is as below:
> itkImageFileReader->itkImageToVTKImageFilter->vtkImageViewer2
> The problem is I always get a core dump when I interact with the slice 
> like moving mouse on it. I don't know why exactly. Since when I just use 
> itk+vtk without using qt, it seems fine, and when I change to import a 
> raw data just using vtk+qt combination, it seems still fine. I believe 
> it has something to do with interactor style or sth, but I'm not sure. 
> Can anybody help me out here? I'm exausted about it. Thank you in 
> advance!Below are my codes:
> 
>     typedef signed short  InputPixelType;
>     typedef unsigned char MaskPixelType;
>     const unsigned int Dimension = 3;
>     typedef itk::Image< InputPixelType, Dimension > InputImageType;
>     typedef itk::Image< MaskPixelType,  Dimension > MaskImageType;
>    
>     typedef itk::ImageFileReader< InputImageType > ReaderType;
> 
>     ReaderType::Pointer reader  = ReaderType::New();
>     reader->SetFileName( 
> "/home/cliff/research/digimouse/ct_380x992x208.hdr" );
>     reader->Update();
>     typedef itk::VTKImageExport< InputImageType > ExportFilter1Type;
>     ExportFilter1Type::Pointer itkExporter1 = ExportFilter1Type::New();
>     itkExporter1->SetInput( reader->GetOutput() );
> 
>     // Create the vtkImageImport and connect it to the
>     // itk::VTKImageExport instance.
>     vtkImageImport* vtkImporter1 = vtkImageImport::New(); 
>     ConnectPipelines(itkExporter1, vtkImporter1);
> 
>     vtkImporter1->Update();
> 
>     vtkSmartPointer<vtkImageData> image = 
> vtkSmartPointer<vtkImageData>::New();
>     image = vtkImporter1->GetOutput();
>    image -> Update();
> 
>     vtkImageViewer2 *viewer = vtkImageViewer2::New();
>     vtkInteractorStyleImage * interactorStyle = 
> vtkInteractorStyleImage::New();
>     interactorStyle->AutoAdjustCameraClippingRangeOff();
>     interactorStyle -> SetInteractor(qvtkWidget->GetInteractor());
>     interactorStyle = viewer->GetInteractorStyle();
>     qvtkWidget->GetInteractor()->SetInteractorStyle( interactorStyle );
>     viewer->SetupInteractor(qvtkWidget->GetInteractor());
>     viewer->SetInput(image);
>     viewer->SetSliceOrientationToXY();
>     viewer->SetSlice(50);
>     viewer->UpdateDisplayExtent();
>     viewer->Render();
>    
>     viewer->SetColorWindow(255);
>     viewer->SetColorLevel(128);
>     viewer->SetRenderWindow(renWin);
>     viewer->SetRenderer(renderer);
> 
>     // Set the background to something grayish
>     renderer->SetBackground(0.4392, 0.5020, 0.5647);
>     //renderer->SetActiveCamera(camera);
>     renderer->ResetCamera();
>     //renderer->ResetCameraClippingRange ();
>     qvtkWidget->GetRenderWindow()->Render();
> 
> 
> 
> ------------------------------------------------------------------------
> ´©Ô½µØÕð´ø ¼ÍÄîãë´¨µØÕðÒ»ÖÜÄê 
> <http://512.mail.163.com/mailstamp/stamp/dz/activity.do?from=footer>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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


-- 
-------------------------------------------------
Bryn Lloyd
Computer Vision Laboratory
ETH Z¨¹rich, Sternwartstrasse 7
CH - 8092 Z¨¹rich, Switzerland
Tel: +41 44 63 26668
Fax: +41 44 63 21199
-------------------------------------------------



More information about the vtkusers mailing list