oh yes rather stupid error... - sorry and thanks for the help!!<br><br>But I still can't see the arrow. I added a translation to put it in the center like this:<br> typedef ArrowType::TransformType trans;<br> trans::OutputVectorType translation;<br>
translation[0]=100;<br> translation[1]=100;<br> translation[2]=100;<br> trans::Pointer transform = trans::New();<br> transform->SetTranslation(translation);<br> myArrow->SetObjectToWorldTransform(transform);<br>
<br>I also specified the values: <br> imageFilter->SetOutsideValue(0);<br> imageFilter->SetInsideValue(100);<br><br>But still the image remains black. After a little search in the itk mailing list I found this:<br>
<pre><br>> <a href="http://www.itk.org/pipermail/insight-users/2005-May/012960.html">http://www.itk.org/pipermail/insight-users/2005-May/012960.html</a><br>> The IsInside() function is not implemented for the ArrowSpatialObject so <br>
> the SpatialObjectToImageFilter cannot be used with this object.<br><br>This was 2005 is this still true? Can't I generate an arrow in an image?<br><br>Thanks.<br>seb<br></pre><br><div class="gmail_quote">On Thu, Aug 19, 2010 at 7:15 PM, Kishore Mosaliganti <span dir="ltr"><<a href="mailto:kishoreraom@gmail.com">kishoreraom@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Sebastian,<br>
<br>
It looks like you did not set size[2] value.<br>
<br>
Kishore<br>
<div><div></div><div class="h5"><br>
On Thu, Aug 19, 2010 at 12:25 PM, Sebastian Jameson<br>
<<a href="mailto:jameson.sebastian@gmail.com">jameson.sebastian@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I'm trying to build an image with spatial objects but whenever I use the<br>
> SpatialObjectToImageFilter an Exception gets thrown:<br>
><br>
> ERROR: ExceptionObject caught !<br>
><br>
> itk::ExceptionObject (0x7f70a0000ca0)<br>
> Location: "TElement* itk::ImportImageContainer<TElementIdentifier,<br>
> TElement>::AllocateElements(TElementIdentifier) const [with<br>
> 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 ><br>
> SpatialObjectToImageFilterType;<br>
><br>
> SpatialObjectToImageFilterType::Pointer imageFilter =<br>
> 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>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</blockquote></div><br>