[vtkusers] problem with the vtkcheckerboard widget
Mark Roden
mmroden at gmail.com
Tue Apr 24 14:49:22 EDT 2012
Hi all,
I'm trying to load two images and look at them in the checkerboard
widget. My problem is that the images are medical images, and also
have different sizes.
They have two different origins. Image 1 has an origin and spacing of:
(0020,0032) Image Position (Patient) DS 3 -239\-154\1218
(0028,0030) Pixel Spacing DS 2 9.3359375e-1\9.3359375e-1
and image 2 has an origin and spacing of:
(0020,0032) Image Position (Patient) DS 3 -286.585938\-201.585938\1216.500000
(0028,0030) Pixel Spacing DS 2 4.000000\4.000000
The point is to be able to check the registration of these two datasets.
When I try to load them using the widget example, I get the following errors:
ERROR: In ..\..\..\VTK\Filtering\vtkStreamingDemandDrivenPipeline.cxx, line 1009
vtkStreamingDemandDrivenPipeline (02B2D6A0): The update extent
specified in the information for output port 0 on algorithm
vtkTrivialProducer(02B2D0D0) is 0 511 0 511 0 0, which is outside the
whole extent 0 143 0 143 0 212.
ERROR: In ..\..\..\VTK\Filtering\vtkImageData.cxx, line 1530
vtkImageData (02AE75A8): GetScalarPointer: Pixel (0, 256, 0) not in memory.
Current extent= (0, 143, 0, 143, 0, 212)
(these errors repeat for several instances, all saying essentially the
same thing).
Once the errors are done, then the images are present, but clearly not
respecting the pixel coordinates at all.
What can I do to make the checkerboard widget (or the wipe widget)
respect pixel spacing and the origin values of the two different
vtkImageData I'm using? (the follow up question will be about using
vtkAffineWidget to adjust the registration, so if there is already a
sample project on how to do that, that would be excellent).
My code, run in Qt 4.8 on vc 2008 with 5.10.0-rc1:
vtkFileOutputWindow* window = vtkFileOutputWindow::New();
window->SetFileName("vtk_errors.txt");
vtkOutputWindow::SetInstance(window);
window->Delete();
//for now, just show the two volumes together
//code from page 282 of the VTK User's Manual
vtkImageCheckerboard* checkers = vtkImageCheckerboard::New();
checkers->SetInput1(theImages->getVolume(0)->getImageData());//theImages
holds vtkImageData objects
checkers->SetInput2(theImages->getVolume(1)->getImageData());
checkers->SetNumberOfDivisions(10,6,1);
vtkImageActor *checkerboardActor = vtkImageActor::New();
checkerboardActor->SetInput(checkers->GetOutput());
vtkCheckerboardRepresentation* rep =
vtkCheckerboardRepresentation::New();
rep->SetCheckerboard(checkers);
rep->SetImageActor(checkerboardActor);
vtkCheckerboardWidget *checkerboardWidget =
vtkCheckerboardWidget::New();
checkerboardWidget->SetRepresentation(rep);
vtkSmartPointer<vtkRenderer> ren1 =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(ren1);
vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
checkerboardWidget->SetInteractor(iren);
ren1->AddActor(checkerboardActor);
ren1->SetBackground(0.1, 0.2, 0.4);
renWin->SetSize(300, 300);
// render the image
//
iren->Initialize();
renWin->Render();
checkerboardWidget->On();
iren->Start();
Thanks!
Mark
More information about the vtkusers
mailing list