<span style="font-family: arial,helvetica,sans-serif;">Dear VTK users,</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">I am writing a program where i need to convert <br>

itk::Image to vtkImageData and vice versa.</span><br style="font-family: arial,helvetica,sans-serif;">
<span style="font-family: arial,helvetica,sans-serif;">I try to separate the code concerning conversion filter<br>(precisely, i have a more complicated hierarchy of classes<br>where one does the conversion and passes an output to other).<br>


</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">Here is a snippet:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;"><b>typedef </b>itk::Image&lt;<b>short int</b>, <b>3</b>&gt; ImageType;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ImageType::Pointer imageITK;           //itk smart pointer to image</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">vtkSmartPointer&lt;vtkImageData&gt; imageVTK;//vtk smart pointer to image</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">//... //loading data to imageITK;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{  //block of conversion itk-&gt;vtk begins</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">   <b>typedef </b>itk::ImageToVTKImageFilter&lt;ImageType&gt; ConverterType;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   ConverterType::Pointer converter = ConverterType::New();</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">   converter-&gt;SetInput(imageITK);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   converter-&gt;Update();</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">   imageVTK = converter-&gt;GetOutput();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}  //block of conversion itk-&gt;vtk ends</span><br style="font-family: courier new,monospace;">


<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">anImageActor-&gt;SetInput(imageVTK);//anImageActor is added to aRenderer props&#39; list</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">aRenderer-&gt;Render();             //segmentation error</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">imageVTK-&gt;Update();              //segmentation error<br>


<br><span style="font-family: arial,helvetica,sans-serif;">It seems to me that after ImageToVTKImageFilter destruction (end of block),</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">it is impossible to access the result of conversion (imageVTK).</span><br style="font-family: arial,helvetica,sans-serif;">

<span style="font-family: arial,helvetica,sans-serif;">Indeed, if you comment out the block parentheses, it works fine.</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">But i have to have this code separate (because of the program structure).</span><br style="font-family: arial,helvetica,sans-serif;">

<span style="font-family: arial,helvetica,sans-serif;">
What could i do? Should i store every filter instances all the program life?</span><br style="font-family: arial,helvetica,sans-serif;"><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">Thanks in advance for reply.</span><br style="font-family: arial,helvetica,sans-serif;">

<span style="font-family: arial,helvetica,sans-serif;">Pawel~</span><br style="font-family: arial,helvetica,sans-serif;"></span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">_________________</span><br style="font-family: arial,helvetica,sans-serif;">


<span style="font-family: arial,helvetica,sans-serif;">Paweł~~Łubniewski</span><br style="font-family: arial,helvetica,sans-serif;"><span style="font-family: arial,helvetica,sans-serif;">__________________________________________________________________________</span><br style="font-family: courier new,monospace;">