[vtkusers] vtkImageReslice

Oscar Esteban Sanz-Dranguet oesteban at die.upm.es
Thu Sep 3 05:03:53 EDT 2009


Hi Tassilo,

I use this code to view the sagital, coronal and transversal planes of 
3D images. I'm not advanced at all using VTK, but I think that it will help.

I suppose image (vtkImage object), reslicer (vtkImageReslice object), 
sliceRenderWin (vtkRenderWindow), sliceFixedActor (vtkActor) and the 
other object previously initialized.
>   // Calculate the center of the volume
>   int extent[6];
>   double spacing[3];
>   double origin[3];
>   image->GetWholeExtent(extent);
>   image->GetSpacing(spacing);
>   image->GetOrigin(origin);
>
>   double center[3];
>   center[0] = origin[0] + spacing[0] * 0.5 * (extent[0] + extent[1]);
>   center[1] = origin[1] + spacing[1] * 0.5 * (extent[2] + extent[3]);
>   center[2] = origin[2] + spacing[2] * 0.5 * (extent[4] + extent[5]);
>
>   // Matrices for axial, coronal, sagittal view orientations
>   static double elements[3][16] = {{
>           1, 0, 0, 0,
>           0, 1, 0, 0,
>           0, 0, 1, 0,
>           0, 0, 0, 1 },{
>           1, 0, 0, 0,
>           0, 0, 1, 0,
>           0,-1, 0, 0,
>           0, 0, 0, 1 },{
>           0, 0,-1, 0,
>           1, 0, 0, 0,
>           0,-1, 0, 0,
>           0, 0, 0, 1 }};
>
>   for (int i=0; i<3; i++)
>     {
>
>     // Set the slice orientation
>     vtkMatrix4x4 *resliceAxes = vtkMatrix4x4::New();
>     resliceAxes->DeepCopy(elements[i]);
>     // Set the point through which to slice
>     resliceAxes->SetElement(0, 3, center[0]);
>     resliceAxes->SetElement(1, 3, center[1]);
>     resliceAxes->SetElement(2, 3, center[2]);
>
>
>     reslicer->SetOutputDimensionality(2);
>     reslicer->SetInterpolationModeToLinear();
>     reslicer->SetInput( image );
>     reslicer->SetResliceAxes(resliceAxes);
>
>     // Setup the RenderWindow and its basic infrastructure
>     sliceRenderWin[i]->SetSize( (i==2)?500:256, (i==2)?500:256);
>     sliceRenderWin[i]->SetPosition(260*i,0);
>     sliceRenderWin[i]->AddRenderer( sliceRenderer[i] );
>     sliceRenderWindowInteractor[i]->SetRenderWindow( sliceRenderWin[i] );
>     sliceRenderer[i]->InteractiveOff();
>     sliceRenderer[i]->SetBackground(0.0, 0.0, 0.0);
>
>     sliceFixedActor[i]->SetInput(reslicer);
>
>     sliceRenderer[i]->AddActor(sliceFixedActor[i]);
>     sliceRenderer[i]->GetActiveCamera()->SetViewUp( 0, -1, 0 );
>     sliceRenderer[i]->ResetCamera();
>     sliceRenderWin[i]->Render();
>     sliceRenderWindowInteractor[i]->Initialize();
>   }
Modifying the elements matrix and center you could get other planes

Cheers,

Oscar Esteban
BIT - UPM (http://www.die.upm.es/im/)
+34 913 366 827 ext.4248



Tassilo Klein escribió:
> Hi at all,
>
> I am somewhat new to VTK. I have a question concerning
> vtkImageReslice. I have got a CT data set and would like to make
> arbitrary oriented slices through the volume. What I basically would
> like to implement is a tracked probe's eye view. From what I have read
> vtkImageReslice is the right choice. Does anybody have an illustrative
> example of how to use vtkImageReslice or can explain how to use it (I
> didn't find the documentation that intuitive)? I played around with it
> but didn't really manage something that met my expectations. Would
> appreciate some help.
>
> Regards,
>  Tassilo
> _______________________________________________
> 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
>
>   



More information about the vtkusers mailing list