[Insight-users] SpatialObjectToImageFilter Exception

Sebastian Jameson jameson.sebastian at gmail.com
Fri Aug 20 13:50:27 EDT 2010


oh yes rather stupid error... - sorry and thanks for the help!!

But I still can't see the arrow. I added a translation to put it in the
center like this:
    typedef ArrowType::TransformType trans;
    trans::OutputVectorType translation;
    translation[0]=100;
    translation[1]=100;
    translation[2]=100;
    trans::Pointer transform = trans::New();
    transform->SetTranslation(translation);
    myArrow->SetObjectToWorldTransform(transform);

I also specified the values:
    imageFilter->SetOutsideValue(0);
    imageFilter->SetInsideValue(100);

But still the image remains black. After a little search in the itk mailing
list I found this:


> http://www.itk.org/pipermail/insight-users/2005-May/012960.html
> The IsInside() function is not implemented for the ArrowSpatialObject so
>  the SpatialObjectToImageFilter cannot be used with this object.

This was 2005 is this still true? Can't I generate an arrow in an image?

Thanks.
seb


On Thu, Aug 19, 2010 at 7:15 PM, Kishore Mosaliganti
<kishoreraom at gmail.com>wrote:

> Hi Sebastian,
>
> It looks like you did not set size[2] value.
>
> Kishore
>
> On Thu, Aug 19, 2010 at 12:25 PM, Sebastian Jameson
> <jameson.sebastian at gmail.com> wrote:
> > Hi,
> >
> > I'm trying to build an image with spatial objects but whenever I use the
> > SpatialObjectToImageFilter an Exception gets thrown:
> >
> > ERROR: ExceptionObject caught !
> >
> > itk::ExceptionObject (0x7f70a0000ca0)
> > Location: "TElement* itk::ImportImageContainer<TElementIdentifier,
> > TElement>::AllocateElements(TElementIdentifier) const [with
> > TElementIdentifier = long unsigned int, TElement = short unsigned int]"
> > File: /itk/InsightToolkit-3.20.0/Code/Common/itkImportImageContainer.txx
> > Line: 188
> > Description: Failed to allocate memory for image.
> >
> >
> > Here is my code:
> >
> >
> >   try
> >     {
> >
> >     typedef itk::ArrowSpatialObject<3>   ArrowType;
> >     ArrowType::Pointer myArrow = ArrowType::New();
> >     myArrow->SetLength(20);
> >
> >     ArrowType::VectorType direction;
> >     direction.Fill(0);
> >     direction[1] = 1.0;
> >     myArrow->SetDirection(direction);
> >
> >     typedef itk::Image< unsigned short, 3 > ImageType;
> >     typedef itk::SpatialObjectToImageFilter< ArrowType, ImageType >
> > SpatialObjectToImageFilterType;
> >
> >     SpatialObjectToImageFilterType::Pointer imageFilter =
> > SpatialObjectToImageFilterType::New();
> >     imageFilter->SetInput(myArrow);
> >
> >     ImageType::SizeType size;
> >     size[ 0 ] = 200;
> >     size[ 1 ] = 200;
> >     imageFilter->SetSize( size );
> >     ImageType::SpacingType spacing;
> >     spacing[0]=1;
> >     spacing[1]=1;
> >     spacing[2]=1;
> >     imageFilter->SetSpacing(spacing);
> >     imageFilter->Update();
> >
> >     typedef itk::ImageFileWriter< ImageType >  WriterType;
> >     WriterType::Pointer writer = WriterType::New();
> >     char * output_name="/tmp/arrow.nrrd" ;
> >     writer->SetFileName( output_name);
> >     writer->SetInput( imageFilter->GetOutput() );
> >
> >     std::cout << "Writing image: " << output_name << std::endl;
> >     writer->Update();
> >     }
> >   catch( itk::ExceptionObject & err )
> >     {
> >     std::cerr << "ERROR: ExceptionObject caught !" << std::endl;
> >     std::cerr << err << std::endl;
> >     }
> >
> >   return EXIT_SUCCESS;
> >
> > What am I doing wrong?
> >
> > Thanks for the help,
> > seb
> >
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.html
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100820/04e0f33d/attachment.htm>


More information about the Insight-users mailing list