[Insight-users] how to modify regions with iterators

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 1 20:21:12 EST 2010


David,

Can it be that by "x", David Pastor was referring to
the "x" component of the pixel index ?


If so, the loop could be:


 while( !imageIterator.IsAtEnd() )
   {
   const int x = imageIterator.GetIndex()[0];
   if( x > 10)
     {
     imageIterator.Set(0);
     }
   ++imageIterator;
  }

and some efficiency will be gained by
using the ImageRegionIteratorWithIndex.



      Regards,


             Luis

----------------------------------------------------
On Wed, Dec 1, 2010 at 3:11 PM, David Doria <daviddoria at gmail.com> wrote:
>> 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
> _____________________________________
> 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