Reslice a volume using the transformation of the rendering

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Reslice a volume using the transformation of the rendering

lucaslovercio
Hi!

I want to apply the rotation that the user does in the rendering, to the
volume. Thus, I want to store it in the position that the user wants.
However, when I apply the transformation and render it, the volume is not
oriented as in the orientation seen in the first window.

Can you help? Any suggestion?

Here is my code



vtkSmartPointer<vtkTIFFReader> reader =
vtkSmartPointer<vtkTIFFReader>::New();
reader->SetFileName("volume.tif"); // Multi slice TIFF
reader->Update();
vtkSmartPointer<vtkImageData> image = reader->GetOutput();

// Color transfer functions

vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> volumeMapper =
vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
volumeMapper->SetInputConnection(reader->GetOutputPort());

vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New();
volume->SetMapper(volumeMapper);

// (To the best of my knowledge) I define this Interactor to rotate the
volume, not the view or camera
vtkSmartPointer<vtkInteractorStyleTrackballActor> style =
vtkSmartPointer<vtkInteractorStyleTrackballActor>::New();

vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(ren1);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renWin);
renderWindowInteractor->SetInteractorStyle( style );

ren1->AddViewProp(volume); //Or AddVolume?
ren1->SetBackground(0,0,0);
ren1->ResetCamera();

renWin->SetSize(800, 800);
renWin->Render();
renderWindowInteractor->Start();

//After the user close the window, I want to apply the transformation to the
original volume
//Probably, my problem is in this section of code

vtkSmartPointer<vtkMatrix4x4> matrixRot =
vtkSmartPointer<vtkMatrix4x4>::New();
volume->GetMatrix(matrixRot);

vtkSmartPointer<vtkImageReslice> reslice =
vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInputConnection(reader->GetOutputPort());
// Rotate about the center of the image?
vtkSmartPointer<vtkTransform> transform =
vtkSmartPointer<vtkTransform>::New();
transform->SetMatrix(matrixRot);
reslice->SetOutputOrigin( reader->GetOutput()->GetOrigin()[0],
reader->GetOutput()->GetOrigin()[1], reader->GetOutput()->GetOrigin()[2]);
reslice->SetResliceTransform(transform);
reslice->SetInterpolationModeToCubic();
reslice->SetOutputSpacing(
reader>GetOutput()->GetSpacing()[0], reader->GetOutput()->GetSpacing()[1],
reader->GetOutput()->GetSpacing()[2]);
reslice->SetOutputExtent(reader->GetOutput()->GetExtent());
reslice->Update();



Thanks in advance.
Lucas




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers