[vtkusers] 2D slice display on the main plane
dean.inglis at camris.ca
dean.inglis at camris.ca
Wed Nov 3 08:52:34 EST 2004
Prashanth,
why not just use vtkImageActor? If all you are doing is
displaying 2D orthogonal axis aligned image planes you can
simplify your pipeline to exclude vtkImageReslice:
<snip>
vtkImageReader2 *vtkImgRdr = vtkImageReader2::New();
vtkImgRdr->ReleaseDataFlagOn();
vtkImgRdr->SetDataByteOrderToBigEndian();
vtkImgRdr->SetDataExtent(0,255,0,255,1,113);
vtkImgRdr->SetDataScalarTypeToUnsignedShort();
vtkImgRdr->SetDataOrigin(-128.5, -128.5, -57);
vtkImgRdr->SetFilePrefix("E:/GUI/sample_code/CTHead/CThead");
vtkImgRdr->Update();
// Following code displays a slice NOT on the overlay plane.
vtkImageActor* actor = vtkImageActor::New();
int axis = 0;
int* extent = vtkImgRdr->GetOutput()->GetExtent();
int midslice = (extent[2*axis+1]-extent[2*axis])/2;
switch(axis)
{
case 0: actor->SetDisplayExtent(midslice,midslice, extent[2],extent[3],extent[4],extent[5]);break;
case 1: actor->SetDisplayExtent(extent[0],extent[1],midslice,midslice, extent[4],extent[5]);break;
case 2: actor->SetDisplayExtent( extent[0],extent[1],extent[2],extent[3],midslice,midslice);break;
deafault: break; // do something appropriate here...
}
vtkRenderer *renAxial= vtkRenderer :: New();
renAxial->AddActor(actor);
renWin->AddRenderer( renAxial );
renWin->SetSize( 500, 500);
<snip>
Dean
hi ,
I need to develop a viewer which displays slices from the 3D volume
data. I would like to render the slices(2D Image) on the main plane, so
that I could draw line annotations over the displayed slices, i.e., on
the overlay plane. As of now, I am able to extract the slices from the
volume, but I am unable to display it on the main plane.
The code I have written to display the slices.
vtkImageReader2 *vtkImgRdr = vtkImageReader2::New();
vtkImgRdr->ReleaseDataFlagOn();
vtkImgRdr->SetDataByteOrderToBigEndian();
vtkImgRdr->SetDataExtent(0,255,0,255,1,113);
vtkImgRdr->SetDataScalarTypeToUnsignedShort();
vtkImgRdr->SetDataOrigin(-128.5, -128.5, -57);
vtkImgRdr->SetFilePrefix("E:/GUI/sample_code/CTHead/CThead");
vtkImgRdr->Update();
vtkImageReslice *axial=vtkImageReslice::New();
axial->SetInput(vtkImgRdr->GetOutput());
axial->SetOutputDimensionality(2);
axial->SetInterpolationModeToCubic();
axial->SetResliceAxesDirectionCosines(1, 0, 0,
0, 1, 0,
0, 0, 1);
axial->Update();
// Following code displays slice on the overlay plane.
vtkImageMapper *axial_mapper=vtkImageMapper::New();
axial_mapper->SetInput(axial->GetOutput());
axial_mapper->SetColorWindow(500);
axial_mapper->SetColorLevel(1000);
vtkActor2D *axial_actor = vtkActor2D::New();
axial_actor->SetMapper(axial_mapper);
vtkRenderer *renAxial= vtkRenderer :: New();
renAxial->AddActor(axial_actor);
renWin->AddRenderer( renAxial );
renWin->SetSize( 500, 500);
vtkRenderWindowInteractor *renInt =
vtkRenderWindowInteractor::New();
renInt->SetRenderWindow(renWin);
renWin->Render();
Can any one suggest, how do we modify the above code to display the
slice on the main plane, instead on an overlay plane, i.e., we need to
replace vtkActor2D, with appropriate Actor for displaying slice on main
plane.
Thanks & Regards
Prashanth
More information about the vtkusers
mailing list