#include <itkImageRandomConstIteratorWithIndex.h>
ImageRandomConstIteratorWithIndex is a multi-dimensional iterator class that is templated over image type. ImageRandomConstIteratorWithIndex is constrained to walk only within the specified region. It samples random pixel positions at each increment or decrement.
ImageRandomConstIteratorWithIndex 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.
The operator++ method provides a simple syntax for walking around a region of a multidimensional image. operator++ performs a jump to a random position within the specified image region. This is designed to facilitate the extraction of random samples from the image.
This is the typical use of this iterator in a loop:
ImageRandomConstIteratorWithIndex<ImageType> it( image, image->GetRequestedRegion() ); it.SetNumberOfSamples(200); it.GoToBegin(); while( !it.IsAtEnd() ) { it.Get(); ++it; // here it jumps to another random position inside the region }
or
ImageRandomConstIteratorWithIndex<ImageType> it( image, image->GetRequestedRegion() ); it.SetNumberOfSamples(200); it.GoToEnd(); while( !it.IsAtBegin() ) { it.Get(); --it; // here it jumps to another random position inside the region }