#include <itkImageLinearConstIteratorWithIndex.h>
ImageLinearConstIteratorWithIndex is templated over image type and is constrained to walk within a specified image region. It is designed for line-by-line processing of images. This iterator walks a linear path along a selected image direction that is parallel to one of the coordinate axes of the image. The iterator conceptually breaks the image into a set of parallel lines that span the selected image dimension.
ImageLinearConstIteratorWithIndex assumes a particular layout of the image data. The is arranged in a 1D array as if it were [][][][slice][row][col] with Index[0] = col, Index[1] = row, Index[2] = slice, etc.
operator++ provides a simple syntax for walking around a region of a multidimensional image. operator++ iterates across a preselected direction constraining the movement to within a region of image. The user can verify when the iterator reaches the boundary of the region along this direction, by calling the IsAtEndOfLine() method. Then it is possible to pass to the next line starting at the first pixel in the row that is part of the region by calling the NextLine() method.
This is the typical use of this iterator in a loop:
ImageLinearConstIteratorWithIndex<ImageType> it( image, image->GetRequestedRegion() ); it.SetDirection(2); it.GoToBegin(); while( !it.IsAtEnd() ) { while( !it.IsAtEndOfLine() ) { value = it.Get(); // it.Set() doesn't exist in the Const Iterator ++it; } it.NextLine(); }