[Insight-users] how to modify regions with iterators

David Doria daviddoria at gmail.com
Wed Dec 1 12:25:21 EST 2010


On Wed, Dec 1, 2010 at 12:21 PM, David Pastor <david.pastor at die.upm.es> wrote:
> Dear all,
>
> I'm trying to modify some image in a very basic way, the idea is
>
> image (x>10)=0
>
> so all the values of the image which x component is bigger than 10 are set
> to 0.
>
> I don't find very obvious to do it with itk iterators... any leads?? maybe
> some filter?

Hi David,

Check out this example:

http://www.itk.org/Wiki/ITK/Examples/Iterators/ImageRegionIterator

You'll want to modify the iterator loop to look like:
  while(!imageIterator.IsAtEnd())
    {
    if(imageIterator.GetIndex()[0] > 10)
      {
      imageIterator.Set(0);
      }
    ++imageIterator;
    }

David


More information about the Insight-users mailing list