[Insight-users] ShapedNeighborhoodIterator problem

David Doria daviddoria at gmail.com
Sun Nov 14 11:31:18 EST 2010


On Sun, Nov 14, 2010 at 8:50 AM, Dawood Masslawi <masslawi at gmail.com>wrote:

> As you indicated the way I activated the offsets would create a ball except
> for a
>
> neighborhood with 1 pixel radius. I think the source of the error is that
> when you
>
> assign a region for a neighborhood iterator even if its smaller than the
> whole image
>
> the neighborhood iterator still would only iterate over that region and not
> outside
>
> (even though your image is defined outside the region, validity of the
> pixels is defined
>
> inside the region only), so the solution is either not to refer to out of
> bound pixels in
>
> the first and last rows and columns or to use the face calculator to handle
> the boundary
>
> checking. I used the face calculator in a similar example and didn't get
> any errors.
>
> Regards,
>
> Dawood
>

Ok, getting closer, just a couple more questions:

1) If I'm going to do this type of thing:

  IteratorType::OffsetType top = {{0,-1}};
  IteratorType::OffsetType bottom = {{0,1}};
  IteratorType::OffsetType left = {{-1,0}};
  IteratorType::OffsetType right = {{1,0}};

Then get the pixels with:
iterator[top][0]

is there an advantage to using the ShapedNeighborhoodIterator over just a
NeighborhoodIterator?

2) If I do want to use the ShapedNeighborhood style, is this correct:

IteratorType::IndexListType::const_iterator indexIterator =
iterator.GetActiveIndexList().begin();
    while (indexIterator != iterator.GetActiveIndexList().end())
      {
     std::cout << (int)iterator[*indexIterator][0] << " ";
      ++indexIterator;
      }

3) If I loop over the ActiveIndexList using the FaceCalculator, is the idea
that in all regions except the 0th region I need to do something like:

IteratorType::IndexListType::const_iterator indexIterator =
iterator.GetActiveIndexList().begin();
    while (indexIterator != iterator.GetActiveIndexList().end())
      {
      bool valid;
      iterator.GetPixel(*indexIterator,valid);
      if(valid) { do something }
      ++indexIterator;
      }

Alternatively, I could use 4 separate loops (one for each face region) where
I know which neighbor isn't valid. I would have to modify the
ActiveIndexList to reflect this missing pixel before each loop.

4) I believe
iterator[top][0]
is equivalent to but faster than iterator.GetPixel(top). Is this correct?

5) Am I correct that the face calculator returns overlapping regions? If I
use a 5x5 image with a 3x3 kernel, it returns regions of size
9
5
5
5
5

totaling 29, when there are only 25 pixels. I don't see any functions to
turn on/off this overlap. How is this usually handled?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101114/8da85289/attachment.htm>


More information about the Insight-users mailing list