[Insight-users] ++ overload in itkindex

Luis Ibanez luis.ibanez at kitware.com
Thu Jan 12 22:19:50 EST 2006

Hi Eduardo,

this operation of index increment is not available in ITK.

In part, because it is ill-defined in N-Dimensional images,
and in part because if you implement it on the index, then
there will be one and only one way of walking through all
the pixels of an image.

    As Jim explained:

         What we use is Image Iterators.

Please read the ITK Software Guide


in particular the chapter on "Image Iterators" on the
developers section.

An image iterator can be initialized in a location
of the image, and then it will walk through the
pixels using the operator ++.

ITK offers a family of ImageIterators, that implement
different strategies on how to walk through the image.

What you probably want is the following code:

    typedef itk::ImageRegionIterator< ImageType > IteratorType;

    IteratorType it( image, image->GetBufferedRegion() );


    while( !it.IsAtEnd() )
      PixelType pp = it.Get();

This code will make the "it" image iterator walk
through the entire image.

You will find more details on the chapter of the
ITK Software Guide that we suggested above.



Eduardo Suarez wrote:
> If i have a
>    itk::Image::RegionType foo;
> is it possible then to
>    foo.GetIndex(0)++
> ?
> -Eduardo
> Miller, James V (GE, Research) wrote:
>> What would operator ++ and -- do on a multidimensional index? 
>> Increment one component
>> of the index?  Increment all components of the index?
>> If you want to move an index around an image, you an use an 
>> ImageRegionIterator
>> Jim
>> -----Original Message-----
>> From: insight-users-bounces+millerjv=crd.ge.com at itk.org
>> [mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of
>> Eduardo Suarez
>> Sent: Thursday, January 12, 2006 1:51 PM
>> To: insight-users at itk.org
>> Cc: Izzat Sabbagh Rodríguez
>> Subject: [Insight-users] ++ overload in itkindex
>> Just wondering why there is no overload of ++ and -- operators in 
>> itkindex.h
>> Regards,
>> -Eduardo
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users

More information about the Insight-users mailing list