ITK/Examples/Iterators/ImageRegionExclusionConstIteratorWithIndex: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
No edit summary
(Deprecated content that is moved to sphinxe)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
==ImageRegionExclusionConstIteratorWithIndex.cxx==
{{warning|1=The media wiki content on this page is no longer maintainedThe 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 "itkImageRegionExclusionConstIteratorWithIndex.h"
 
typedef itk::Image<int, 2> ImageType;
 
static void CreateImage(ImageType::Pointer);
 
int main(int argc, char*argv[])
{
 
  ImageType::SizeType exclusionRegionSize;
  exclusionRegionSize.Fill(2);
 
  ImageType::IndexType exclusionRegionIndex;
  exclusionRegionIndex.Fill(0);
 
  ImageType::RegionType exclusionRegion(exclusionRegionIndex, exclusionRegionSize);
 
  ImageType::Pointer image = ImageType::New();
  CreateImage(image);
    
  itk::ImageRegionExclusionConstIteratorWithIndex<ImageType> imageIterator(image, image->GetLargestPossibleRegion());
  imageIterator.SetExclusionRegion(exclusionRegion);
 
  unsigned int numberVisited = 0;
  while(!imageIterator.IsAtEnd())
    {
    std::cout << imageIterator.Get() << std::endl;
    ++imageIterator;
    ++numberVisited;
    }
   
  std::cout << "Visited " << numberVisited << std::endl;
 
  return EXIT_SUCCESS;
}
 
void CreateImage(ImageType::Pointer image)
{
  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);
 
}
</source>
 
{{ITKCMakeLists|ImageRegionExclusionConstIteratorWithIndex}}

Latest revision as of 14:07, 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.