[vtkusers] slicing through vtkImagedata
David Gobbi
dgobbi at irus.rri.on.ca
Thu Jun 7 11:47:17 EDT 2001
Hi Matthias,
There are some changes to the default OutputExtent etc. for
vtkImageReslice. The way that the defaults are handled is
described in the header file and documenatation.
One way to fix the code is to make the rotation occur
about the center of the image, i.e.
transform = vtkTransform()
transform.Translate(-255.5,-255.5,-59.5)
transform.RotateX(90)
transform.Translate(+255.5,+255.5,+59.5)
Another way is to use the new SetResliceAxesDirectionCosines()
method instead of the SetResliceTransform() method -- one nice
thing about this is that you get a rotation of _exactly_ 90
degrees, while transform.RotateX(90) gives a rotation of only
_approximately_ 90 degrees (because of roundoff error in the math).
reslice.SetResliceAxesDirectionCosines((+1,0,0, 0,0,+1, 0,-1,0))
You can check the RotateImage.py example for yet another method
of ensuring that the rotation occurs about the center of the image.
- David
--
David Gobbi, MSc dgobbi at irus.rri.on.ca
Advanced Imaging Research Group
Robarts Research Institute, University of Western Ontario
On Thu, 7 Jun 2001, Matthias Zangl wrote:
> Hello everybody,
>
> I've written a program that loads some slices (TIFF), stores them in an
> imagedata-object (reader.GetOutput). And I try to get slices through every
> axes (x,y,z) as well as free cutted slices.
>
> I used the following python-code:
>
> ---
> from libVTKCommonPython import *
> from libVTKGraphicsPython import *
> from WindowLevelInterface import *
>
> reader = vtkTIFFReader()
> reader.SetFilePrefix("C:\\source\\dicoms\\daten\\bud\\raw\\i.")
> reader.SetFilePattern("%s%.3d.tif")
> reader.SetDataExtent(0,512,0,512,1,120)
> reader.Update()
>
> transform = vtkTransform()
> transform.RotateX(90)
>
> reslice = vtkImageReslice()
> reslice.SetInput(reader.GetOutput())
> reslice.SetResliceTransform(transform)
> reslice.SetInterpolationModeToLinear()
> reslice.SetOutputSpacing(1,1,1)
>
> viewer = vtkImageViewer()
> viewer.SetInput(reslice.GetOutput())
> viewer.SetColorWindow(256)
> viewer.SetColorLevel(127.5)
> viewer.SetZSlice(0)
> viewer.Render()
>
> WindowLevelInterface(viewer)
> ---
>
>
> But, these lines of code worked well with the binary-installation of vtk
> 3.2. Now I checked out the actual nightly build and it isn't working with
> that one. I suppose that the RotateX-method rotates the voxels out of the
> visible area. When I use the mirror-function (Reslice.Mirror) I can see that
> my object was turned around 90° but it is displayed twice and a half.
>
> I assume that the transformation is working, but turning around the wrong
> point, origin?
>
> Does anything have changed regarding the transformation, or image-reslices?
>
> Thanks in advance for your help!
>
> Matthias
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list