[Insight-users] Region.PadByRadius results in infinite loop during iteration

Bill Lorensen bill.lorensen at gmail.com
Thu Nov 22 12:37:07 EST 2007


Have you printed the region?

On Nov 22, 2007 10:46 AM, Charlotte Curtis <curtisc at uoguelph.ca> wrote:

> 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->GetAxisAlignedBoundingBox Region();
>
>
> 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?
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071122/f3250c3d/attachment.html


More information about the Insight-users mailing list