Cross-section images

David Gobbi dgobbi at irus.rri.on.ca
Mon Aug 30 16:41:56 EDT 1999


Hi Ron,

The default OutputExtent is made large enough to fit the
entire input extent after transformation.  The details
are in the ExecuteInformation method of the cxx file.
Often, this is not what you want, and you will have to set
the OutputExtent yourself.  To know what you should
set the OutputExtent to, you need to know exactly what
the Spacing, Origin, and Extent mean from a VTK standpoint.  

The TextureReslice.tcl example deals with this issue.
(personally, I find the TextureReslice.py example more
readable ;)

Here is a snippet of a previous email I wrote on the topic:

==========================================================

First you have to ensure that you are reading the image properly.  The
volume an N*M*S block of voxels contained within the bounds
(xmin xmax ymin ymax zmin zmax).  The bounds will have some sort of units
attached to them, e.g. in medical images millimetres are used.

An example:  you have some raw data for a 256x256x93 image volume,
and the size of each voxel is exactly 0.81 mm in x,y and 1.2 in z.
Furthermore, the centre of the lower-left-rear voxel of the image
lies at coordinates (-100 mm,-100 mm,-50 mm).  Then, when you
read the image, you specify

% vtkImageReader reader
% reader SetFileName "file"
% reader SetDataExtent 0 255 0 255 0 92
% reader SetDataSpacing 0.81 0.81 1.2
% reader SetDataOrigin -100.0 -100.0 -50.0

So, what are the bounds of this image, i.e. what extent of x,y,z space
does it cover?  You can get this information using

% reader UpdateInformation
% reader GetBounds
> -100.0 106.55 -100.0 106.55 -50.0 60.4 

Or you can calculate the bounds yourself, e.g. the x bounds are
(DataOrigin[0] + DataExtent[0]*DataSpacing[0],
 DataOrigin[0] + DataExtent[1]*DataSpacing[0])
== (-100.0 +   0*0.81,
    -100.0 + 255*0.81)

If you ever use the imaging pipeline, engrave the following
equations into your skull:

x = i*spacing[0] + origin[0]
y = j*spacing[1] + origin[1]
z = k*spacing[2] + origin[2]

and conversely,

i = (x - origin[0])/spacing[0]
j = (y - origin[1])/spacing[1]
k = (z - origin[2])/spacing[2]

Apply these equations to go between 'Bounds' (i.e. coordinate limits)
and 'Extent' (i.e. index limits).

==========================================================

Hopefully this will help.

 - David

--David Gobbi, MSc                    dgobbi at irus.rri.on.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Mon, 30 Aug 1999, Ron Inbar wrote:

> Hi David!
> 
> Just after mailing the original message, I came across your vtkImageReslice
> in the man pages.  I saw that it can do what I need, but I had trouble
> figuring out exactly how it works.  Namely, I didn't understand how it
> determines its OutputExtent.  I connected it to a 512x512x35 volume and got
> an output extent of (0 430 0 430 0 270) Could you please explain?  I'd be
> most grateful.
> 
> Regards,
> 
> Ron
> 
> ----- Original Message -----
> From: David Gobbi <dgobbi at irus.rri.on.ca>
> To: Ron Inbar <rinbar at netvision.net.il>
> Cc: VTK Mailing List <vtkusers at gsao.med.ge.com>
> Sent: Monday, August 30, 1999 20:14
> Subject: Re: Cross-section images
> 
> 
> > Hi Ron,
> >
> > The vtkImageReslice class in the contrib directory does what you want.
> > There is a new example in the nightlies which should provide a
> > good starting point:  vtk/contrib/examplesTcl/TextureReslice.tcl (thanks
> > to Kenneth Wang for converting it from python to tcl, and Bill Lorenson
> > for quality control).
> >
> > The example extracts an oblique slice from a volume and texture maps
> > it back into the scene; a vtkTransform defines which slice to extract.
> > The original TestReslice.tcl example is still kicking around, too.
> >
> >  - David
> >
> 
> 



-----------------------------------------------------------------------------
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