[vtkusers] ImageToVTKImageFilter in separate block error

Paweł~~Łubniewski lubniewski at gmail.com
Wed Feb 17 05:41:43 EST 2010


Dear VTK users,
I am writing a program where i need to convert
itk::Image to vtkImageData and vice versa.
I try to separate the code concerning conversion filter
(precisely, i have a more complicated hierarchy of classes
where one does the conversion and passes an output to other).

Here is a snippet:

*typedef *itk::Image<*short int*, *3*> ImageType;
ImageType::Pointer imageITK;           //itk smart pointer to image
vtkSmartPointer<vtkImageData> imageVTK;//vtk smart pointer to image

//... //loading data to imageITK;

{  //block of conversion itk->vtk begins
   *typedef *itk::ImageToVTKImageFilter<ImageType> ConverterType;
   ConverterType::Pointer converter = ConverterType::New();
   converter->SetInput(imageITK);
   converter->Update();
   imageVTK = converter->GetOutput();
}  //block of conversion itk->vtk ends

anImageActor->SetInput(imageVTK);//anImageActor is added to aRenderer props'
list
aRenderer->Render();             //segmentation error
imageVTK->Update();              //segmentation error

It seems to me that after ImageToVTKImageFilter destruction (end of block),
it is impossible to access the result of conversion (imageVTK).
Indeed, if you comment out the block parentheses, it works fine.
But i have to have this code separate (because of the program structure).
 What could i do? Should i store every filter instances all the program
life?

Thanks in advance for reply.
Pawel~

_________________
Paweł~~Łubniewski
__________________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100217/432ad5e3/attachment.htm>


More information about the vtkusers mailing list