ITK/Examples/Iterators/ImageRandomNonRepeatingConstIteratorWithIndex: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
No edit summary
(Deprecated content that is moved to sphinxe)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
==ImageRandomNonRepeatingConstIteratorWithIndex.cxx==
{{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/pages likely require ITK version 4.13 or earlier releasesIn many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
<source lang="cpp">
}}
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageRandomNonRepeatingConstIteratorWithIndex.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;
}
 
</source>
 
{{ITKCMakeLists|{{SUBPAGENAME}}}}

Latest revision as of 14:21, 6 June 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.