[vtkusers] Can't figure out the reslice
Doug Hoppes
dhoppes at mbfbioscience.com
Mon May 17 08:09:50 EDT 2010
Okay, I'm not sure what I'm missing here. I was able to read my image
in and I thought that I was creating a slice that was at 45 degrees to
the entire volume (cut the entire volume diagonally). However, the only
thing that seems to be happening is that I'm taking the topmost layer of
the volume and rotating it by 45 degrees.
Any help is greatly appreciated.
Doug
-----------------
// Read the image data file
vtkSmartPointer<vtkTIFFReader> pReader =
vtkSmartPointer<vtkTIFFReader>::New();
pReader->SetFilePrefix("TestImages\\sample\\test_");
pReader->SetFilePattern("%s%03d.tif");
pReader->SetDataScalarTypeToUnsignedChar();
pReader->SetNumberOfScalarComponents(3);
pReader->SetDataOrigin(0,0,0);
pReader->SetDataSpacing(1,1,1);
pReader->SetFileLowerLeft(0);
pReader->SetDataExtent(0, 246, 0, 174, 0, 25);
// Define the axis and what type of orientation for the slice to display
AxisDirection eAxis = Multi;
double dAngle = 45;
double dAngleInRadians = dAngle * (PI/180.0);
// Create the reslice object
vtkSmartPointer<vtkImageReslice> pImageSlice =
vtkSmartPointer<vtkImageReslice>::New();
pImageSlice->SetResliceAxesOrigin(0, 0, 0);
pImageSlice->SetResliceAxesDirectionCosines(cos(dAngleInRadians),
-sin(dAngleInRadians), 0.0,
sin(dAngleInRadians),
cos(dAngleInRadians), 0.0,
0.0, 0.0,
1.0);
// Extract a slice in the desired orientation
pImageSlice->SetInputConnection(pReader->GetOutputPort());
pImageSlice->SetOutputDimensionality(2);
pImageSlice->SetInterpolationModeToLinear();
// Create the actor
vtkSmartPointer<vtkImageActor> pImageActor =
vtkSmartPointer<vtkImageActor>::New();
pImageActor->SetInput(pImageSlice->GetOutput());
pImageActor->SetPosition(0,0,0);
// Add Actor to renderer
pRenderer->AddViewProp(pImageActor);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100517/50c95285/attachment.htm>
More information about the vtkusers
mailing list