[Insight-users] neighborhood iterator
Jiao Lin
jiao.lin at gmail.com
Wed Feb 16 13:13:44 EST 2011
Hi Robert,
Thanks for your quick response! That is certainly a solution. But the
SetLocation method is not optimized for speed so I wonder if there is
a better way to do it.
--Jiao
On Wed, Feb 16, 2011 at 10:11 AM, robert tamburo
<robert.tamburo at gmail.com> wrote:
> 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
>
>
More information about the Insight-users
mailing list