[Insight-developers] Bug in ImageLinearIterator class?

Luis Ibanez ibanez@choroid.cs.unc.edu
Tue, 8 May 2001 14:46:46 -0400 (EDT)


Paul,

Thanks for pointing this out.
The documentation is broken.



This is the correct use of the ImageLinearIterator:
(following your example of a ramp)


// Fill image with a ramp
itk::ImageLinearIterator<ImageType> iter(image, region);
itk::ImageLinearIterator<ImageType>::IndexType index;
PixelType value;

iter.Begin();

iter.SetDirection( 0 ); // go along X,
// It is quite important to set this direction

while( !iter.IsAtEnd() )
{
   while( !iter.IsAtEndOfLine() )
   {
     index = iter.GetIndex();
     value = index[0] + index[1];
     iter.Set( value );
     ++iter;  // advance to next pixel
   }
   iter.NextLine(); // advance to next line
}


I'll fix the documentation and set your ramp as a test in
the Testing directory.


Thanks

Luis