[vtkusers] help! reslice a raw image

Yang, Faguo Faguo.Yang at STJUDE.ORG
Tue Jan 6 10:42:35 EST 2009


Thank you guys. Just as you guys said the problem is the file.
 Scalars must have a name "scalars"

Thanks a lot!
yang

________________________________
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of stevannindya henryanto
Sent: 2009年1月6日 4:00
To: vtkusers at vtk.org
Subject: [vtkusers] help! reslice a raw image

Hello,
I'm trying to view an image from 3D raw volume. I'm using vtkImageReslice for doing it. But, I got a blank view after viewing the output using vtkImageViewer. Here is my code :

------------------------------------------------------------------------------------------------
vtkImageReader2 *reader = vtkImageReader2::New();
reader->SetFileName("prone8.raw");
reader->SetFileDimensionality(3);
reader->SetDataByteOrderToBigEndian();
reader->SetNumberOfScalarComponents(1);
reader->SetDataExtent(0, 511, 0, 511, 0, 462);
reader->SetDataSpacing(0.625, 0.625, 1.0);
reader->SetDataOrigin(0.0, 0.0, 0.0);
reader->UpdateWholeExtent();
//calculate the center of the volume
reader->GetOutput()->UpdateInformation();
int extent[6];
double spacing[3];
double origin[3];
reader->GetOutput()->GetWholeExtent(extent);
reader->GetOutput()->GetSpacing(spacing);
reader->GetOutput()->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]));
//matrix for axial view
static double axialElements[16] = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1};
//set slice orientation
vtkMatrix4x4 *resliceAxes = vtkMatrix4x4::New();
resliceAxes->DeepCopy(axialElements);

//set the point through which to slice
//set i,j setElement(i,j,double);
resliceAxes->SetElement(0, 3, center[0]);
resliceAxes->SetElement(1, 3, center[1]);
resliceAxes->SetElement(2, 3, center[2]);

//extract slice
vtkImageReslice *reslice = vtkImageReslice::New();
reslice->SetInputConnection(reader->GetOutputPort());
reslice->SetOutputDimensionality(2);
reslice->SetResliceAxes(resliceAxes);
reslice->SetInterpolationModeToLinear();

// Create a greyscale lookup table
vtkLookupTable *table = vtkLookupTable::New();
table->SetRange(0, 2000); // 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
vtkImageMapToColors *color = vtkImageMapToColors::New();
color->SetLookupTable(table);
color->SetInputConnection(reslice->GetOutputPort());
/
//view the image
viewer = vtkImageViewer2::New();
viewer->SetInput(color->GetOutput());
viewer->SetSize(512,512);
// viewer->SetZSlice(sliderValueChanged());
qvtk->SetRenderWindow(viewer->GetRenderWindow());
reader->Delete();
------------------------------------------------------------------------------------------------

I'm using qt3 here. Plese help me....
Thanks...







________________________________
Email Disclaimer: www.stjude.org/emaildisclaimer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090106/8a1c28f7/attachment.htm>


More information about the vtkusers mailing list