[vtkusers] Can't figure out the reslice
Bill Lorensen
bill.lorensen at gmail.com
Mon May 17 08:26:31 EDT 2010
Your direction cosines look like you are rotating the plane about the
z-axis by 45 degrees. And that plane passes through the origin (first
voxel). So I think you are getting what you asked for.
ill
On Mon, May 17, 2010 at 8:09 AM, Doug Hoppes <dhoppes at mbfbioscience.com> wrote:
> 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);
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
More information about the vtkusers
mailing list