Do you call <span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">m_EllipseToImageFilter->Update() before setting </span>tempBinaryPtr ?<br><br><div class="gmail_quote">
On Sun, Mar 6, 2011 at 7:31 PM, Alexander Taghva <span dir="ltr"><<a href="mailto:alextaghva@gmail.com">alextaghva@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br>
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:<br>
<br>
//////////////////////////////////////////////////////////////////////////<br>
<br>
// In the header file<br>
typedef itk::EllipseSpatialObject<3> EllipseType;<br>
typedef itk::SpatialObjectToImageFilter<EllipseType, BinaryImageType> EllipseToImageFilterType; <br>
typedef unsigned char BinaryPixelType;<br>
typedef itk::Image<BinaryPixelType, 3> BinaryImageType;<br>
typedef typename BinaryImageType::Pointer BinaryImagePointer;<br>
<br>
<br>
// in the txx file<br>
<br>
typename Superclass::InputImageConstPointer inputPtr = this->GetInput();<br>
// m_EllipseToImageFilter is my SpatialObjectToImageFilter<br>
BinaryImagePointer tempBinaryPtr = m_EllipseToImageFilter->GetOutput(); <br>
<br>
typedef itk::ImageRegionConstIterator<TInputImage> InputIterator;<br>
typedef itk::ImageRegionConstIterator<BinaryImageType> TempBinaryIterator;<br>
<br>
InputIterator inputIt( inputPtr, inputPtr->GetRequestedRegion() );<br>
TempBinaryIterator tempBinaryIt( tempBinaryPtr, tempBinaryPtr->GetRequestedRegion() );<br>
<br>
cout << "Seg fault happens here " << std::endl;<br>
for( inputIt.GoToBegin(), tempBinaryIt.GoToBegin();
!inputIt.IsAtEnd() && !tempBinaryIt.IsAtEnd() ; ++inputIt,
++tempBinaryIt ) <br>
{ <br>
if ( tempBinaryIt.Get() > 0 )<br>
// do something else;<br>
}<br>
<br>
<br>
///////////////////////////////////////////////<br>
<br>
Alex<br clear="all"><br>
<br>_____________________________________<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></blockquote></div><br>