ITK  4.8.0
Insight Segmentation and Registration Toolkit
WikiExamples/Iterators/ImageRandomNonRepeatingConstIteratorWithIndex.cxx
#include "itkImage.h"
int main(int argc, char*argv[])
{
typedef itk::Image<unsigned char, 2> ImageType;
ImageType::Pointer image = ImageType::New();
ImageType::SizeType regionSize;
regionSize.Fill(3);
ImageType::IndexType regionIndex;
regionIndex.Fill(0);
ImageType::RegionType region(regionIndex, regionSize);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
itk::ImageRandomNonRepeatingConstIteratorWithIndex<ImageType> imageIterator(image, image->GetLargestPossibleRegion());
imageIterator.SetNumberOfSamples(region.GetNumberOfPixels());
imageIterator.GoToBegin();
while(!imageIterator.IsAtEnd())
{
std::cout << imageIterator.GetIndex() << std::endl;
++imageIterator;
}
return EXIT_SUCCESS;
}