[vtkusers] Re: using vtkImageReslice with external data arrays

David Gobbi dgobbi at atamai.com
Thu Feb 10 14:32:58 EST 2005

See below for replies to your questions.

On Thu, 10 Feb 2005, Marius S Giurgi wrote:

> Hi, David
> As vtkImageReslice is mostly your creation I thought I'd ask the master
> a very specific question.
> Please give me a hint, at your own convenience.
> The application I am trying to develop is dealing with processing MRI
> data, and I am going to use the vtkImageReslice to mainly to introduce
> motion to the brain data (rotation/translation), and I'd like this
> motion computation to be as quick as possible. I have a pointer to the
> actual 3D brain image (directly read from the disk) as a set of
> 181x217x181 double array. This data gets altered throughout the
> application, therefore I need to have a pointer to it available,
> besides having it wrapped into a vtkImageData object. Eventually, I
> need to pass this data to the reslicer to put the motion in, therefore
> I was wondering how can I get a hold on a pointer to the reslicer
> output data. I know I could use the vtkImageExport to get a hold on
> that pointer, but my question is does this pointer remain the same once
> I create the reslicer and produce its output?

The pointer to the output data changes every time the Extent of the output
changes.  So, if you update the whole extent once, get the pointer, and
then make sure the extent never changes, it should work.  But isn't
very safe!

Also, note that with vtkImageExport, if you want to get a pointer without
copying any data, you have to use the GetPointerToData() method and not
the GetExportVoidPointer() method.

> Say, I use the importer to wrap my data into a vtkImageData, pass it to
> the vtkImageReslice, and then get its output, and finally use the
> exporter to get the pointer to the output data. If I modify the
> transformation matrix connected to vtkImageReslice and have the result
> updated, will the output go into the same place so I can access it
> through the same pointer?

As long as the Output's Extent never changes, it should work.

> To put it shortly, I'd like to have two pointers, one to the input data
> and one to the output data and let the vtkImageReslice do the work,
> avoiding any unnecessary copy of data. Eventually, the rigid rotation
> is just value mapping of an input grid onto an output grid, right?

Yes, but of course VTK is in control of the memory so you have to be

 - David

> marius
> "To be really medieval, one should have no body. To be really
> modern, one should have no soul. To be really Greek, one should
> have no clothes."
>   -- Oscar Wilde

More information about the vtkusers mailing list