[vtkusers] vtkImageReslice and vtkImageViewer
Talita Perciano
talitaperciano at gmail.com
Thu Sep 25 11:01:42 EDT 2008
Hi,
I'm trying to read a DICOM volume and extract orthogonal slices from it
using vtkImageReslice. After I extract the slice I'm using a vtkImageViewer
to view the slice. Here is the code:
std::string strFolderPath = "/home/talita/Desktop/WRIX/WRIST RIGHT/T2
TSE AX FS RT. - 3";
reader = vtkDICOMImageReader::New();
reader->SetDirectoryName(strFolderPath.c_str());
reader->Update();
reader->SetDataScalarTypeToUnsignedShort();
reader->UpdateWholeExtent();
reader->GetOutput()->UpdateInformation();
double sp[3];
reader->GetOutput()->GetSpacing(sp);
int extent[6];
double origin[3];
reader->GetOutput()->GetWholeExtent(extent);
reader->GetOutput()->GetOrigin(origin);
double center[3];
center[0] = origin[0] + sp[0] * 0.5 * (extent[0] + extent[1]);
center[1] = origin[1] + sp[1] * 0.5 * (extent[2] + extent[3]);
center[2] = origin[2] + sp[2] * 0.5 * (extent[4] + extent[5]);
// Matrices for axial, coronal, sagittal, oblique view orientations
static double axialElements[16] = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1 };
static double coronalElements[16] = {
1, 0, 0, 0,
0, 0, 1, 0,
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 };
vtkMatrix4x4 *resliceAxes = vtkMatrix4x4::New();
resliceAxes->DeepCopy(axialElements);
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
vtkImageReslice *reslice = vtkImageReslice::New();
reslice->SetInputConnection(reader->GetOutputPort());
reslice->SetOutputDimensionality(2);
reslice->SetResliceAxes(resliceAxes);
//reslice->SetInterpolationModeToNearestNeighbor();
// renArea->get_vtk_viewer() returns a vtkImageViewer
renArea->get_vtk_viewer()->SetInputConnection(reslice->GetOutputPort());
renArea->get_vtk_viewer()->SetColorWindow(255);
renArea->get_vtk_viewer()->SetColorLevel(127);
renArea->get_vtk_viewer()->Render();
Why I can't see the slice? Everything is black! Could anyone help me?
Thank you,
Talita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080925/2da69153/attachment.htm>
More information about the vtkusers
mailing list