[Insight-users] how to iterate over the output of a filter

Alexander Taghva alextaghva at gmail.com
Sun Mar 6 20:05:30 EST 2011


I was not.  That fixed it.  Thanks.

On Sun, Mar 6, 2011 at 4:37 PM, robert tamburo <robert.tamburo at gmail.com>wrote:

> Do you call m_EllipseToImageFilter->Update() before setting
> tempBinaryPtr ?
>
> On Sun, Mar 6, 2011 at 7:31 PM, Alexander Taghva <alextaghva at gmail.com>wrote:
>
>> Hello,
>> I'm having some trouble doing something that seems like it should be
>> simple to do.  I am writing a composite filter, and I would like to iterate
>> over the output of one of the component filters.  In my program, it is a
>> SpatialObjectToImageFilter templated over an ellipse spatial object and
>> binary image.  I get a seg fault when I try to do it like so.  Thanks for
>> any help. The key parts of the code are below:
>>
>> //////////////////////////////////////////////////////////////////////////
>>
>> // In the header file
>>   typedef itk::EllipseSpatialObject<3> EllipseType;
>>   typedef itk::SpatialObjectToImageFilter<EllipseType, BinaryImageType>
>> EllipseToImageFilterType;
>>   typedef unsigned char BinaryPixelType;
>>   typedef itk::Image<BinaryPixelType, 3>               BinaryImageType;
>>   typedef typename     BinaryImageType::Pointer    BinaryImagePointer;
>>
>>
>> // in the txx file
>>
>>   typename Superclass::InputImageConstPointer  inputPtr =
>> this->GetInput();
>>  // m_EllipseToImageFilter is my SpatialObjectToImageFilter
>>   BinaryImagePointer  tempBinaryPtr =
>> m_EllipseToImageFilter->GetOutput();
>>
>>   typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;
>>   typedef itk::ImageRegionConstIterator<BinaryImageType>
>> TempBinaryIterator;
>>
>>   InputIterator  inputIt(  inputPtr,  inputPtr->GetRequestedRegion() );
>>   TempBinaryIterator tempBinaryIt( tempBinaryPtr,
>> tempBinaryPtr->GetRequestedRegion() );
>>
>>     cout << "Seg fault happens here " << std::endl;
>>     for( inputIt.GoToBegin(), tempBinaryIt.GoToBegin(); !inputIt.IsAtEnd()
>> && !tempBinaryIt.IsAtEnd() ; ++inputIt, ++tempBinaryIt )
>>   {
>>             if ( tempBinaryIt.Get() > 0 )
>>                 // do something else;
>>     }
>>
>>
>> ///////////////////////////////////////////////
>>
>> Alex
>>
>>
>> _____________________________________
>> 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
>>
>>
>


-- 
Alexander Taghva, MD
Department of Neurological Surgery
Keck School of Medicine, University of Southern California
Fellow, Functional Neurosurgery at Ohio State University
614-366-2420
alextaghva at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110306/28076c37/attachment.htm>


More information about the Insight-users mailing list