[vtkusers] vtkImageReslice problem
Jothy
jothybasu at gmail.com
Mon Oct 4 09:22:03 EDT 2010
Hi all,
I am using vtkImageReslice to slice an 3D image data. But the problem is
whatever slice value I set, it return the same image.
Can someone have a look at the transformation matrix and the code, please?
// Calculate the center of the volume
this->center[0] = this->origin[0] + this->spacing[0] * 0.5 *
(this->extent[0] + this->extent[1]);
this->center[1] = this->origin[1] + this->spacing[1] * 0.5 *
(this->extent[2] + this->extent[3]);
this->center[2] = this->origin[2] + this->spacing[2] * 0.5 *
(this->extent[4] +this->extent[5]);
qDebug()<<this->center[0]<<this->center[1]<<this->center[2];
// Matrices for axial, coronal, sagittal, oblique view orientations
// double axialElements[16] = {
// 1, 0, 0, 0,
// 0, 1, 0, 1,
// 0, 0, 1, sliceA,
// 0, 0, 0, 1 };
static double coronalElements[16] = {
1, 0, 0, 0,
0, 0, 1, sliceA,
0,-1, 0, 0,
0, 0, 0, 1 };
// static double sagittalElements[16] = {
// 0, 0,-1, 0,
// 1, 0, 0, 0,
// 0,-1, 0, 0,
// 0, 0, 0, 1 };
//static double obliqueElements[16] = {
// 1, 0, 0, 0,
// 0, 0.866025, -0.5, 0,
// 0, 0.5, 0.866025, 0,
// 0, 0, 0, 1 };
// Set the slice orientation
vtkSmartPointer<vtkMatrix4x4> resliceAxes =
vtkSmartPointer<vtkMatrix4x4>::New();
resliceAxes->DeepCopy(coronalElements);
// 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]);
// Extract a slice in the desired orientation
vtkSmartPointer<vtkImageReslice> reslice =
vtkSmartPointer<vtkImageReslice>::New();
reslice->SetInput(this->imgData);
reslice->SetOutputDimensionality(2);
reslice->SetResliceAxesOrigin(10,20,20);
reslice->SetResliceAxes(resliceAxes);
reslice->SetInterpolationModeToLinear();
// reslice->GetOutput()->UpdateInformation();
// reslice->GetOutput()->UpdateData();
// reslice->GetOutput()->Update();
// Create a greyscale lookup table
vtkSmartPointer<vtkLookupTable> table =
vtkSmartPointer<vtkLookupTable>::New();
table->SetRange(-300, 900); // image intensity range
table->SetValueRange(0.0, 1.0); // from black to white
table->SetSaturationRange(0.0, 0.0); // no color saturation
table->SetRampToLinear();
table->Build();
// Map the image through the lookup table
vtkSmartPointer<vtkImageMapToColors> color =
vtkSmartPointer<vtkImageMapToColors>::New();
color->SetLookupTable(table);
color->SetInput(reslice->GetOutput());
// Display the image
this->actor =vtkImageActor::New();
actor->SetInput(color->GetOutput());
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
// vtkSmartPointer<vtkRenderWindow> window =
// vtkSmartPointer<vtkRenderWindow>::New();
this->ui->AxialWidget->GetRenderWindow()->AddRenderer(renderer);
// Set up the interaction
vtkSmartPointer<vtkInteractorStyleImage> imageStyle =
vtkSmartPointer<vtkInteractorStyleImage>::New();
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetInteractorStyle(imageStyle);
this->ui->AxialWidget->GetRenderWindow()->SetInteractor(interactor);
this->ui->AxialWidget->GetRenderWindow()->Render();
// this->ui->AxialWidget->show();
Thanks,
Jothy
--
Research Scholar
Dept. of Medical Physics
Clatterbridge Centre for Oncology
UK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101004/bb3c6e3f/attachment.htm>
More information about the vtkusers
mailing list