ImageReslice in vtk23

David Gobbi dgobbi at irus.rri.on.ca
Thu Jul 8 13:11:46 EDT 1999


On Thu, 8 Jul 1999, Ana Cugat wrote:

> Thank you very much David,
> 
> If I set OptimizationOff it works.

Good.  This was probably the bug I thought it was.
 
> The second method does not work, I get the same bizarre thing.

Well, thanks for trying both methods.   
 
> I don't quite understand why it worked before anyway. By the way, the 
> OutputExtent actualizes on its own  (if it was 0 127 0 127 1 90 then the new 
> outputextent is 0 127 1 90 0 127), but the outputorigin gives a strange 
> result (goes from 0 0 0 to -3.8147e-06 -0.499996 -0.5 ). What is its meaning 
> and must it be modified?

A vtk Image has two coordinate systems associated with it:
'index' coordinates are integers (i,j,k) and which count voxels,
'image' coordinates are real numbers (x,y,z) and refer to distances
(usually mm or inches).

The Origin and Spacing of an image are used to convert 'index' 
coordinates to 'image' coordinates and vice versa,

x = Origin[0] + Spacing[0]*i
y = Origin[1] + Spacing[1]*j
z = Origin[2] + Spacing[2]*k

Finally, the Extent describes the range of indices covered by the
image.

By default, when you read an image using vtkImageReader, the Origin
is (0.0, 0.0, 0.0),  so the (x,y,z) coordinates of (0,0,0) are at
the lower-left corner. 

And when you use vtkImageReslice, the geometrical transformation is
computed in terms of (x,y,z) coordinates, so you will be rotating
around the lower-left hand corner.  You probably want to rotate
the image around its center, in which case you could do a little
math and figure out the transformation which will do this.

Getting back to your comment, if you don't set OutputOrigin and
OutputExtent then a set of heuristics will be used to generate them
automatically:

1) the OutputExtent is set just large enough that the entire transformed
   image is visable.

2) the OutputOrigin is set so that the (x,y,z) coordinates of the
   center of the new image are the same as the coordinates of the
   center of the old image.

Also, the OutputSpacing is always set to a default of 1.0, 1.0, 1.0.

So, when you let the OutputOrigin be calculated automatically you
sometimes get strange numbers, particularly if the spacing of the
original image was not 1.0, 1.0, 1.0.

> Thanks again,

You're very welcome.

 - David

> >From: David Gobbi <dgobbi at irus.rri.on.ca>
> >To: Ana Cugat <c1f6326 at hotmail.com>
> >CC: vtkusers at gsao.med.ge.com
> >Subject: Re: ImageReslice in vtk23
> >Date: Wed, 7 Jul 1999 15:03:48 -0400 (EDT)
> >
> >Hi Ana,
> >
> >If this is the bug I think it is, it was fixed a while ago -- but
> >probably after vtk2.3 was released.
> >
> >There are two ways to fix this.  First, try using the OptimizationOff()
> >flag on vtkImageReslice (though this will cause the filter to run
> >around 50% slower).
> >
> >The second method:  Instead of doing a rotation by approximately -90
> >degrees
> >
> >   vtkTransform transform
> >     transform RotateY -90.0
> >
> >build a permutation matrix that rotates by exactly -90 degrees
> >
> >   vtkMatrix4x4 matrix
> >     matrix SetElement 0 0  0.0
> >     matrix SetElement 0 2 -1.0
> >     matrix SetElement 2 2  0.0
> >     matrix SetElement 2 0  1.0
> >
> >   vtkTransform transform
> >     transform Concatenate matrix
> >
> >This should solve your problem, if not, email me back.
> >
> >Thanks for the bug report.
> >
> >  - David
> >
> >--David Gobbi, MSc                    dgobbi at irus.rri.on.ca
> >   Advanced Imaging Research Group
> >   Robarts Research Institute, University of Western Ontario
> >
> >On Wed, 7 Jul 1999, Ana Cugat wrote:
> >
> > > I would like to know if there is any problem with vtkImageReslice. I 
> >used
> > > with vtk22 and I had no problem, but the same application running with 
> >vtk23
> > > produces strange results!!!
> > >
> > > If I do:
> > >
> > > vtkTransform transform
> > > transform Identity
> > > transform RotateY -90.0
> > >
> > > vtkImageReslice reslice
> > > reslice SetResliceTransform transform
> > > reslice SetInput [reader GetOutput]
> > >
> > >
> > > it doesn't work while it worked with vtk22. I think has to do with
> > > SetOutputExtent, but I didn't use it with vtk22 and it worked??!
> > >
> > >
> > >
> > >
> > >
> > > Ana Cugat
> > >
> > >
> > > ______________________________________________________
> > > Get Your Private, Free Email at http://www.hotmail.com
> > >
> > >
> > > 
> >-----------------------------------------------------------------------------
> > > This is the private VTK discussion list.  Please keep messages on-topic.
> > > Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> > > To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
> > > <majordomo at gsao.med.ge.com>.  For help, send message body containing
> > > "info vtkusers" to the same address.     Live long and prosper.
> > > 
> >-----------------------------------------------------------------------------
> > >
> >
> >
> >
> >-----------------------------------------------------------------------------
> >This is the private VTK discussion list.  Please keep messages on-topic.
> >Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> >To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
> ><majordomo at gsao.med.ge.com>.  For help, send message body containing
> >"info vtkusers" to the same address.     Live long and prosper.
> >-----------------------------------------------------------------------------
> >
> 
> 
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> 





-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list