Have you printed the region? <br><br><div class="gmail_quote">On Nov 22, 2007 10:46 AM, Charlotte Curtis <<a href="mailto:curtisc@uoguelph.ca">curtisc@uoguelph.ca</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'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. My image is
fairly large, but only a small portion of it is non-zero (it's a
segmentation), so I don't want to waste time iterating through the
whole image. The code that doesn't work is as follows:
<br><br>typedef itk::ImageMaskSpatialObject< Dimension > MaskType;<br>MaskType::Pointer mask = MaskType::New();<br>mask->SetImage( image1 );<br>ImageType::RegionType boundingBoxRegion = mask->GetAxisAlignedBoundingBox
<div>Region();
<br><br>boundingBoxRegion.PadByRadius(10);<br><br>ConstIteratorType itr1(image1, boundingBoxRegion);<br><br>for (itr1.GoToBegin(); !itr1.IsAtEnd(); ++itr1)<br> {<br> vol1 += itr1.Get() ? 1 : 0;<br> }<br><br>
The
reason I am doing this is to compare two manual segmentations of the
same object. It works just fine if I iterate over the entire image,
but it takes a while. It also works if I don't try to pad the region,
but then I won't get accurate results because the discrepancies of one
segmentation may be slightly outside of the
AxisAlignedBoundingBoxRegion of the other. 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. However, the
iteration loop keeps on going until it seg faults. Is there something
else I should be doing to slightly increase the size of my bounding
box?
</div>
<br>_______________________________________________<br>Insight-users mailing list<br><a href="mailto:Insight-users@itk.org">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>