[Insight-developers] Misleading ImageRegionConstIterator example

David Doria daviddoria at gmail.com
Thu May 31 14:16:19 EDT 2012


On this page:

http://www.itk.org/Doxygen/html/classitk_1_1ImageRegionConstIterator.html

there is an example that shows the use of an iterator:

      it = it.Begin();
      for (; !it.IsAtEnd(); ++it)
         {
         *it += 100.0;
         }

There are two problems with this. First, the iterators don't seem to
provide this * operator for dereferencing. Second, it is the const
iterator page, and the data is being modified.

I propose changing this to:

      it = it.Begin();
      for (; !it.IsAtEnd(); ++it)
         {
         std::cout << it.Get();
         }

or similar. Seem reasonable?

David


More information about the Insight-developers mailing list