[vtkusers] Problem about vtkImageViewer2 when using itk+vtk+Qt
iconme
iconme at 163.com
Fri May 29 10:21:59 EDT 2009
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();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090529/d417b8b1/attachment.htm>
More information about the vtkusers
mailing list