Hi,<br><br>I&#39;m trying to build an image with spatial objects but whenever I use the SpatialObjectToImageFilter an Exception gets thrown: <br><br>ERROR: ExceptionObject caught !<br><br>itk::ExceptionObject (0x7f70a0000ca0)<br>
Location: &quot;TElement* itk::ImportImageContainer&lt;TElementIdentifier, TElement&gt;::AllocateElements(TElementIdentifier) const [with TElementIdentifier = long unsigned int, TElement = short unsigned int]&quot; <br>File: /itk/InsightToolkit-3.20.0/Code/Common/itkImportImageContainer.txx<br>
Line: 188<br>Description: Failed to allocate memory for image.<br><br><br>Here is my code: <br><br><br>  try <br>    { <br><br>    typedef itk::ArrowSpatialObject&lt;3&gt;   ArrowType;<br>    ArrowType::Pointer myArrow = ArrowType::New(); <br>
    myArrow-&gt;SetLength(20);<br><br>    ArrowType::VectorType direction;<br>    direction.Fill(0);<br>    direction[1] = 1.0;<br>    myArrow-&gt;SetDirection(direction);<br><br>    typedef itk::Image&lt; unsigned short, 3 &gt; ImageType;<br>
    typedef itk::SpatialObjectToImageFilter&lt; ArrowType, ImageType &gt; SpatialObjectToImageFilterType;<br><br>    SpatialObjectToImageFilterType::Pointer imageFilter =  SpatialObjectToImageFilterType::New();<br>    imageFilter-&gt;SetInput(myArrow);<br>
<br>    ImageType::SizeType size;<br>    size[ 0 ] = 200;<br>    size[ 1 ] = 200;<br>    imageFilter-&gt;SetSize( size );<br>    ImageType::SpacingType spacing;<br>    spacing[0]=1;<br>    spacing[1]=1;<br>    spacing[2]=1;<br>
    imageFilter-&gt;SetSpacing(spacing);<br>    imageFilter-&gt;Update();<br><br>    typedef itk::ImageFileWriter&lt; ImageType &gt;  WriterType;<br>    WriterType::Pointer writer = WriterType::New();<br>    char * output_name=&quot;/tmp/arrow.nrrd&quot; ;<br>
    writer-&gt;SetFileName( output_name);<br>    writer-&gt;SetInput( imageFilter-&gt;GetOutput() );<br><br>    std::cout &lt;&lt; &quot;Writing image: &quot; &lt;&lt; output_name &lt;&lt; std::endl;<br>    writer-&gt;Update();<br>
    } <br>  catch( itk::ExceptionObject &amp; err ) <br>    { <br>    std::cerr &lt;&lt; &quot;ERROR: ExceptionObject caught !&quot; &lt;&lt; std::endl; <br>    std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>    } <br><br>
  return EXIT_SUCCESS;<br><br>What am I doing wrong?<br><br>Thanks for the help,<br>seb<br>