[vtkusers] vtkImageImport

David Gobbi david.gobbi at gmail.com
Mon Mar 29 16:07:46 EDT 2010


On Mon, Mar 29, 2010 at 1:33 PM, Erik Türke <tuerke at cbs.mpg.de> wrote:
> On 03/29/2010 08:40 PM, David Gobbi wrote:
>>
>> On Mon, Mar 29, 2010 at 12:26 PM, Erik Türke<tuerke at cbs.mpg.de>  wrote:
>>
>>
>>>
>>> Hi!
>>>
>>> Well, this should be part of an adapter...so the user should get a list
>>> of
>>> pointers to vtkImageData objects (i return a list since the adapter also
>>> gets 4d data as input).
>>> But it seems, this is not possible, so i have to return a list of
>>> pointers
>>> to vtkImageImport objects, what imho is a little odd for the user of the
>>> adapter.
>>>
>>
>> I don't understand what you are trying to say.  Can you give more detail?
>>
>>   David
>>
>
> Hi
>
> I want to write an adapter which takes an image object of an own type and
> returns a list of vtkImageData type pointers, like:
>
> data::ImageList imgList = isis::data::IOFactory::load("data.nii", "");
>
> or
>
> isis::data::ImageList imgList = isis::data::IOFactory::load("data.v", "");
>
> imgList is the image object of type own, which i want to transform into a
> vtkImageData object, like
>
> std::list<vtkImageData*> vtkList =
> isis::adapter::VTKAdapter::makeVtkImageList(imgList.front());
>
> (do not be confused of the imgList.front()...this is an object of dimension
> 4, so i want to return a list of 3d vtkdata)
>
> So, if someone for instance write an vtk image viewer which should support
> the isis image type, he/she can use the VTKAdapter to transform my own
> imagetype into a vtkImageData type and use it.
>
> But the way things are going i have to return vtkImageImport objects:
>
> std::list<vtkImageImport*> vtkList =
> isis::adapter::VTKAdapter::makeVtkImageList(imgList.front());
>
> which actually was not my goal.


Well, I am not familiar with isis, but now I have an idea of what you
are trying to do.

First, note that when using STL containers with VTK objects, you must
always use smart pointers:

  std::vector<vtkSmartPointer<vtkImageData> > imageDataVector;

Smart pointers are the only way that the VTK garbage collector can
track objects that are inside of STL containers.


As for the rest, I really don't understand why you cannot make a list
of vtkImageData objects.  Why not do something like this?

For each 3D image:

1) create a vtkImageImport
2) set the vtkImageImport up for your data
3) call Update
4) use GetOutput() to get the vtkImageData
5) add the vtkImageData to a std:list<vtkSmartPointer<vtkImageData> > container
6) call Delete on the vtkImageImport
7) repeat for the next 3D image

I have used a similar technique for importing 4D image to VTK with no problem.

  David



More information about the vtkusers mailing list