Charlotte,<br><br>After you pad a region by a radius, the region may extend beyond the region of the image. You should use the Crop method applied to your region. You should crop the padded region by the buffered region of your image.
<br><br>In fact, in itk itself, the call to PadByRadius is always followed by a Crop. For example several filters have code like this:<br><br>////////////////////<br>&nbsp; typename TInputImage::RegionType inputRequestedRegion;
<br>&nbsp; inputRequestedRegion = inputPtr-&gt;GetRequestedRegion();<br><br>&nbsp; // pad the input requested region by the operator radius<br>&nbsp; inputRequestedRegion.PadByRadius( radius );<br><br>&nbsp; // crop the input requested region at the input&#39;s largest possible region
<br>&nbsp; if ( inputRequestedRegion.Crop(inputPtr-&gt;GetLargestPossibleRegion()) )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; inputPtr-&gt;SetRequestedRegion( inputRequestedRegion );<br>&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp; }<br>/////////////////<br><br>Of course, your code should not go into an infinite loop, so there is still a problem. Please submit a bug 
<br><br><a href="http://public.kitware.com/Bug/my_view_page.php">http://public.kitware.com/Bug/my_view_page.php</a><br><br>You will need to create an account if you do not already have one.<br><br>Bill<br><br><div class="gmail_quote">
On Nov 22, 2007 12:37 PM, Bill Lorensen &lt;<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Have you printed the region? <br><br><div class="gmail_quote"><div><div></div><div class="Wj3C7c">On Nov 22, 2007 10:46 AM, Charlotte Curtis &lt;<a href="mailto:curtisc@uoguelph.ca" target="_blank">curtisc@uoguelph.ca</a>
&gt; wrote:<br></div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
I&#39;m trying to iterate over a subregion of an image, but the iterator
never seems to know when it reaches the end of the region.&nbsp; My image is
fairly large, but only a small portion of it is non-zero (it&#39;s a
segmentation), so I don&#39;t want to waste time iterating through the
whole image.&nbsp; The code that doesn&#39;t work is as follows:
<br><br>typedef itk::ImageMaskSpatialObject&lt; Dimension &gt;&nbsp;&nbsp; MaskType;<br>MaskType::Pointer&nbsp; mask = MaskType::New();<br>mask-&gt;SetImage( image1 );<br>ImageType::RegionType boundingBoxRegion = mask-&gt;GetAxisAlignedBoundingBox
<div>Region();
<br><br>boundingBoxRegion.PadByRadius(10);<br><br>ConstIteratorType itr1(image1, boundingBoxRegion);<br><br>for (itr1.GoToBegin(); !itr1.IsAtEnd(); ++itr1)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;vol1 += itr1.Get() ? 1 : 0;<br>&nbsp;&nbsp;&nbsp; }<br><br>


The
reason I am doing this is to compare two manual segmentations of the
same object.&nbsp; It works just fine if I iterate over the entire image,
but it takes a while.&nbsp; It also works if I don&#39;t try to pad the region,
but then I won&#39;t get accurate results because the discrepancies of one
segmentation may be slightly outside of the
AxisAlignedBoundingBoxRegion of the other.&nbsp; 10 voxels seems like a fair
margin of error, I doubt I could be off by that much in my manual
segmentation, so it seemed a reasonable approach.&nbsp; However, the
iteration loop keeps on going until it seg faults.&nbsp; Is there something
else I should be doing to slightly increase the size of my bounding
box?
</div></div></div>
<br>_______________________________________________<br>Insight-users mailing list<br><a href="mailto:Insight-users@itk.org" target="_blank">Insight-users@itk.org</a><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>
</blockquote></div><br>