[Insight-users] Region.PadByRadius results in infinite loop during
iteration
Charlotte Curtis
curtisc at uoguelph.ca
Thu Nov 22 10:46:44 EST 2007
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:
typedef itk::ImageMaskSpatialObject< Dimension > MaskType;
MaskType::Pointer mask = MaskType::New();
mask->SetImage( image1 );
ImageType::RegionType boundingBoxRegion =
mask->GetAxisAlignedBoundingBoxRegion();
boundingBoxRegion.PadByRadius(10);
ConstIteratorType itr1(image1, boundingBoxRegion);
for (itr1.GoToBegin(); !itr1.IsAtEnd(); ++itr1)
{
vol1 += itr1.Get() ? 1 : 0;
}
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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071122/da960436/attachment.html
More information about the Insight-users
mailing list