[vtkusers] about reslicing a volume
David Gobbi
dgobbi at irus.rri.on.ca
Mon Dec 4 15:30:06 EST 2000
On Mon, 4 Dec 2000, Fabrice Vincent wrote:
> Hi,
>
> I read a volume with vtkImageReader. I then would like to view one slice of the volume, with a
> variable orientation but always
> passing through a same point (say voxel P( i,j,k)).
>
> I think one way to do this is to use vtkImageReslice, but my problem is :
> which slice (Zslice) from the resliced volume is the one passing through the point P ?
Hi Vincent,
If you only want one slice, then you should set the OutputExtent of
vtkImageReslice to cover only one slice, i.e. something like this:
reslice.SetOutputOrigin(originx, originy, 0.0)
reslice.SetOutputSpacing(spacingx, spacingy, 1.0)
reslice.SetOutputExtent(XILOW,XIHIGH,YILOW,YIHIGH,0,0)
this will extract a slice that covers the plane:
xmin = originx + spacingx*XILOW, xmax = originx + spacingx*XIHIGH
ymin = originy + spacingy*YILOW, ymax = originy + spacingy*YIHIGH
where this plane lies at z = 0. Note that you can choose originx,originy,
spacingx,spacingy and XILOW,XIHIGH, YILOW,YIHIGH to be anything you
desire. It is often wisest to choose them so that the defined plane has
its center at coordinate (0,0,0).
So now you just have to find the geometrical transformation which,
when applied to the aforementioned plane, places it so that it
slices through your data at the desired location. If the plane
has its center at (0,0,0), then your transformation to rotate by
the desired angles and then translate to the coordinates that you want
to be your center of rotation.
If the voxel you want to rotate around is i,j,k then the coordinates of
that voxel are
(xo + xs*i, yo + ys*i, zo + zs*k)
where (xo,yo,zo) = input.GetOrigin()
(xs,ys,zs) = input.GetSpacing()
and 'input' is reslice.GetInput() i.e. whatever data you are using as
input to vtkImageReslice. You will have set up the origin and spacing
when you originally read in the data.
Hope this helps. The most important thing is to think about your images
in terms of (x,y,z) data coordinates, not as (i,j,k) voxel indices. And
it is also important to be able to fluently convert between coordinates
and indices.
- David
--
David Gobbi, MSc dgobbi at irus.rri.on.ca
Advanced Imaging Research Group
Robarts Research Institute, University of Western Ontario
More information about the vtkusers
mailing list