[Insight-users] neighborhood iterator

robert tamburo robert.tamburo at gmail.com
Wed Feb 16 13:11:59 EST 2011


As you iterate the image, check to see if you're on the grid. If you are,
then set and iterate the neighborhood. Something like:

while(!it.IsAtEnd())
  {
  index = it.GetIndex();
  if( (index[0] % 2 == 0) && (index[1] % 3 == 0) )  // or whatever
    {
    neighborhoodIt.SetLocation(index);
    // iterateTheNeighborhood
    .
    .
    .
    }

  ++it;
  }

On Wed, Feb 16, 2011 at 12:40 PM, linjiao <jiao.lin at gmail.com> wrote:

>
> Have a question regarding neighborhood iterator. My understanding is that
> after creating a neighborhood iterator, one can move the center of a
> neighborhood around an image region by increment the iterator:
>
> while (!it.IsAtEnd()) {
>  ...
>  ++it;
> }
>
> Each increment will bring the center to the next pixel in the image region.
> I am now wondering if it is possible to define a "grid" in the image
> region,
> and only let the center to move to the next pixel in that grid.
>
> So for example, we have a 10X10 image, right now we can define a
> neighborhood iterator whose center walks like this
>
> (0,0), (1,0), (2,0), .... (9,0), (0,1), (1,1) ....
>
> I am wondering if we can define a neighborhood iterator whose center walks
> in 2 steps in x direction, and 3 steps in y direction
>
> (0,0), (2,0), (4,0), ... (8,0), (0,3), (2,3), (4,3), ...
>
> Any hints are very appreciated.
>
> --Jiao
> --
> View this message in context:
> http://old.nabble.com/neighborhood-iterator-tp30936654p30936654.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110216/67bd3dc3/attachment.htm>


More information about the Insight-users mailing list