[Insight-users] how to modify regions with iterators

David Doria daviddoria at gmail.com
Wed Dec 1 15:11:42 EST 2010


> I don't think that's what he wants. I'm not that experienced with ITK,
> so I cannot produce working code just like that, but you'll need two
> iterators. One of them will iterate over x (and can be a ConstIterator,
> or something like that) and the other will iterate over image. Something
> like:
>
> while(!imageIterator.IsAtEnd())
>    {
>    if xConstIterator.Get()>10
>        {
>        imageIterator.Set(0)
>        }
>    ++imageIterator;
>    ++xConstIterator;
>    }
>
> Not sure if there are any filters that allow you to do this efficiently.
> I always have a hard time finding the filters that I need, which
> actually prevents me from using ITK more often than I do now...
>
> Best,
> Koen

Oh, I see. Why do you need two iterators though? Doesn't this do the trick:

 while(!imageIterator.IsAtEnd())
   {
   if(imageIterator.Get() > 10)
     {
     imageIterator.Set(0);
     }
   ++imageIterator;
   }

David


More information about the Insight-users mailing list