Hi,<br>I am using the ImportImageFilter to assign a datablock to an image. The problem I am facing is that when i return the output of this filter in a function, the image pointer apparently contains no data even though I have let the filter manage the data. I have included a small sample code. Is this a bug or am I missing something?<br>
Thanks,<br>Krishnan<br><br>/* ====================================================== */<br>#include &quot;itkImageFileWriter.h&quot;<br>#include &quot;itkImportImageFilter.h&quot;<br><br>typedef short PixelType;<br>int const Dims3D=3, Dims2D=2;<br>
typedef itk::Image&lt;PixelType, Dims3D&gt; ImageType3D;<br><br>ImageType3D::Pointer func(void)<br>{<br>    typedef itk::ImportImageFilter&lt;PixelType, Dims3D&gt; Import_Filter_Type;<br>    Import_Filter_Type::Pointer importFilter=Import_Filter_Type::New();<br>
    Import_Filter_Type::SizeType size;<br>    size[0] = 51;<br>    size[1] = 51;<br>    size[2] = 60;<br>    Import_Filter_Type::IndexType start;<br>    start.Fill(0);<br>    Import_Filter_Type::RegionType region;<br>    region.SetSize(size);<br>
    region.SetIndex(start);<br>    double Origin[Dims3D];<br>    Origin[0]=Origin[1]=Origin[2]=0.0;<br>    importFilter-&gt;SetRegion(region);<br>    importFilter-&gt;SetOrigin(Origin);<br>    Origin[0]=Origin[1]=Origin[2]=1.0;<br>
    importFilter-&gt;SetSpacing(Origin);//Reuse; just for demo code<br>    short *buf=new short[size[0]*size[1]*size[2]];<br>    importFilter-&gt;SetImportPointer(buf,size[0]*size[1]*size[2], true);<br>    try<br>    {<br>
        importFilter-&gt;Update();<br>    }<br>    catch(itk::ExceptionObject &amp;ob)<br>    {<br>        std::cout&lt;&lt;ob&lt;&lt;std::endl;<br>        getchar();<br>    }<br>    return importFilter-&gt;GetOutput();<br>
}<br>int main( int argc, char **argv)<br>{<br>  typedef itk::ImageFileWriter&lt;ImageType3D&gt; WriterType;<br>  WriterType::Pointer writer = WriterType::New();<br>  ImageType3D::Pointer im = func();<br><br>  writer-&gt;SetInput(im);<br>
  writer-&gt;SetFileName(&quot;test.mhd&quot;);<br>  try<br>  {<br>      writer-&gt;Update();<br>  }<br>  catch(itk::ExceptionObject &amp;ob)<br>  {<br>      std::cout&lt;&lt;ob&lt;&lt;std::endl;<br>  }<br>  <br>  return 0;<br>
}<br><br>