[vtkusers] Problem with vtkImageReslice

Øystein Skotheim oystein+vtk at edge.no
Tue Nov 1 11:25:04 EST 2005


Hello. I am tring to use vtkImageReslice in combination with 
vtkImagePlaneWidget. I use a callback on the InteractionEvent of the 
ImagePlaneWidget to get information about the selected plane. Then I want to 
display this slice as a 2D zoomable image with vtkImageViewer2.

The problem is that I get the following error from VTK when I change the 
position or orientation of the plane in vtkImagePlaneWidget:

ERROR: In 
/Users/oystein/cvs/VTK/Filtering/vtkStreamingDemandDrivenPipeline.cxx, line 630 
vtkStreamingDemandDrivenPipeline (0x27fb880): The update extent specified in 
the information for output port 0 on algorithm vtkImageReslice(0x27e9ef0) is 0 
255 0 255 0 0, which is outside the whole extent 0 255 0 98 0 0.

Can anyone give me a hint on how I can resolve this problem?

I use VTK from CVS together with Qt (vtkqt is a QVTKWidget)

This is how I set up the pipeline:

   /* Create filter for reslicing */
   Reslicer = vtkImageReslice::New();
   Reslicer->SetInput(volume.getVtkVolume());
   Reslicer->SetOutputDimensionality(2);
   Reslicer->SetInterpolationModeToCubic();
   Reslicer->AutoCropOutputOn();

   /* Initially set reslice axes and origin */
   Reslicer->SetResliceAxesDirectionCosines(1,0,0, 0,1,0, 0,0,1);
   Reslicer->SetResliceAxesOrigin(0,0,0);

   /* Set up helper class for viewing 2D images in the scene */
   ImageViewer = vtkImageViewer2::New();
   ImageViewer->SetInput(Reslicer->GetOutput());

   /* Set up interactor */
   QVTKInteractor *interactor = QVTKInteractor::New();
   vtkInteractorStyleImage *style = vtkInteractorStyleImage::New();
   interactor->SetInteractorStyle(style); style->Delete();

   /* Let vtkImageViewer2 control the GUI manager render window */
   vtkqt->SetRenderWindow(ImageViewer->GetRenderWindow());
   interactor->SetRenderWindow(vtkqt->GetRenderWindow());

   ImageViewer->SetupInteractor(interactor);
   ImageViewer->Render();

--cut--

This is the callback for the InteractionEvent of the Image Plane Widget:

class cbPlaneChangedOrientation : public vtkCommand
{
  public:
   static cbPlaneChangedOrientation *New() { return new 
cbPlaneChangedOrientation; }

   virtual void Execute(vtkObject *caller, unsigned long, void*)
   {

     double o[3], normal[3];
     double p1[3], v1[3], vv1;
     double p2[3], v2[3], vv2;
     int DisplayExtent[6];

     vtkImagePlaneWidget *ipw = reinterpret_cast<vtkImagePlaneWidget*>(caller);

     ipw->GetNormal(normal);
     ipw->GetOrigin(o);
     ipw->GetPoint1(p1);
     ipw->GetPoint2(p2);

     // Calculate direction cosines for ImageReslice
     v1[0] = p1[0]-o[0]; v2[0] = p2[0]-o[0];
     v1[1] = p1[1]-o[1]; v2[1] = p2[1]-o[1];
     v1[2] = p1[2]-o[2]; v2[2] = p2[2]-o[2];

     // Normalize vectors
     vv1 = sqrt(v1[0]*v1[0]+v1[1]*v1[1]+v1[2]*v1[2]);
     vv2 = sqrt(v2[0]*v2[0]+v2[1]*v2[1]+v2[2]*v2[2]);

     v1[0] /= vv1; v1[1] /= vv1; v1[2] /= vv1;
     v2[0] /= vv2; v2[1] /= vv2; v2[2] /= vv2;

     ImageSliceRenderer::Reslicer->SetResliceAxesOrigin(o);
   ImageSliceRenderer::Reslicer->SetResliceAxesDirectionCosines(v1,v2,normal);
     ImageSliceRenderer::Reslicer->Update();

     GUIManager::instance().getRenderWidget()->render();

   }
};

Thanks a lot in advance!

---

Øystein Skotheim, Research Scientist
SINTEF ICT, Dept. of Optical Measurement Systems
N-7465 Trondheim, Norway


More information about the vtkusers mailing list