Hi,<br><br>I'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: "TElement* itk::ImportImageContainer<TElementIdentifier, TElement>::AllocateElements(TElementIdentifier) const [with TElementIdentifier = long unsigned int, TElement = short unsigned int]" <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<3> ArrowType;<br> ArrowType::Pointer myArrow = ArrowType::New(); <br>
myArrow->SetLength(20);<br><br> ArrowType::VectorType direction;<br> direction.Fill(0);<br> direction[1] = 1.0;<br> myArrow->SetDirection(direction);<br><br> typedef itk::Image< unsigned short, 3 > ImageType;<br>
typedef itk::SpatialObjectToImageFilter< ArrowType, ImageType > SpatialObjectToImageFilterType;<br><br> SpatialObjectToImageFilterType::Pointer imageFilter = SpatialObjectToImageFilterType::New();<br> imageFilter->SetInput(myArrow);<br>
<br> ImageType::SizeType size;<br> size[ 0 ] = 200;<br> size[ 1 ] = 200;<br> imageFilter->SetSize( size );<br> ImageType::SpacingType spacing;<br> spacing[0]=1;<br> spacing[1]=1;<br> spacing[2]=1;<br>
imageFilter->SetSpacing(spacing);<br> imageFilter->Update();<br><br> typedef itk::ImageFileWriter< ImageType > WriterType;<br> WriterType::Pointer writer = WriterType::New();<br> char * output_name="/tmp/arrow.nrrd" ;<br>
writer->SetFileName( output_name);<br> writer->SetInput( imageFilter->GetOutput() );<br><br> std::cout << "Writing image: " << output_name << std::endl;<br> writer->Update();<br>
} <br> catch( itk::ExceptionObject & err ) <br> { <br> std::cerr << "ERROR: ExceptionObject caught !" << std::endl; <br> std::cerr << err << std::endl; <br> } <br><br>
return EXIT_SUCCESS;<br><br>What am I doing wrong?<br><br>Thanks for the help,<br>seb<br>