Check out the ShapedNeighborhoodIterator class. I have not used it before, but the description sounds like it may work. You can set the neighborhood pixels to iterate by adding the offsets to an active list.<div><div><div>
<br><div class="gmail_quote">On Wed, Feb 16, 2011 at 1:13 PM, Jiao Lin <span dir="ltr"><<a href="mailto:jiao.lin@gmail.com">jiao.lin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Robert,<br>
<br>
Thanks for your quick response! That is certainly a solution. But the<br>
SetLocation method is not optimized for speed so I wonder if there is<br>
a better way to do it.<br>
<br>
--Jiao<br>
<div><div></div><div class="h5"><br>
On Wed, Feb 16, 2011 at 10:11 AM, robert tamburo<br>
<<a href="mailto:robert.tamburo@gmail.com">robert.tamburo@gmail.com</a>> wrote:<br>
> As you iterate the image, check to see if you're on the grid. If you are,<br>
> then set and iterate the neighborhood. Something like:<br>
> while(!it.IsAtEnd())<br>
> {<br>
> index = it.GetIndex();<br>
> if( (index[0] % 2 == 0) && (index[1] % 3 == 0) ) // or whatever<br>
> {<br>
> neighborhoodIt.SetLocation(index);<br>
> // iterateTheNeighborhood<br>
> .<br>
> .<br>
> .<br>
> }<br>
> ++it;<br>
> }<br>
><br>
> On Wed, Feb 16, 2011 at 12:40 PM, linjiao <<a href="mailto:jiao.lin@gmail.com">jiao.lin@gmail.com</a>> wrote:<br>
>><br>
>> Have a question regarding neighborhood iterator. My understanding is that<br>
>> after creating a neighborhood iterator, one can move the center of a<br>
>> neighborhood around an image region by increment the iterator:<br>
>><br>
>> while (!it.IsAtEnd()) {<br>
>> ...<br>
>> ++it;<br>
>> }<br>
>><br>
>> Each increment will bring the center to the next pixel in the image<br>
>> region.<br>
>> I am now wondering if it is possible to define a "grid" in the image<br>
>> region,<br>
>> and only let the center to move to the next pixel in that grid.<br>
>><br>
>> So for example, we have a 10X10 image, right now we can define a<br>
>> neighborhood iterator whose center walks like this<br>
>><br>
>> (0,0), (1,0), (2,0), .... (9,0), (0,1), (1,1) ....<br>
>><br>
>> I am wondering if we can define a neighborhood iterator whose center walks<br>
>> in 2 steps in x direction, and 3 steps in y direction<br>
>><br>
>> (0,0), (2,0), (4,0), ... (8,0), (0,3), (2,3), (4,3), ...<br>
>><br>
>> Any hints are very appreciated.<br>
>><br>
>> --Jiao<br>
>> --<br>
>> View this message in context:<br>
>> <a href="http://old.nabble.com/neighborhood-iterator-tp30936654p30936654.html" target="_blank">http://old.nabble.com/neighborhood-iterator-tp30936654p30936654.html</a><br>
>> Sent from the ITK - Users mailing list archive at Nabble.com.<br>
>><br>
>> _____________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Visit other Kitware open-source projects at<br>
>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Kitware offers ITK Training Courses, for more information visit:<br>
>> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
>><br>
>> Please keep messages on-topic and check the ITK FAQ at:<br>
>> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</div></div></blockquote></div><br></div></div></div>