ITK/Examples/Iterators/ShapedNeighborhoodIterator: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Bad character)
(Deprecated content that is moved to sphinx)
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
==ShapedNeighborhoodIterator.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 releases.   In 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 "itkShapedNeighborhoodIterator.h"
#include "itkImageRegionIterator.h"
#include "itkNeighborhoodAlgorithm.h"
//#include "itkFlatStructuringElement.h"
#include "itkBinaryBallStructuringElement.h"


typedef itk::Image<unsigned int, 2>  ImageType;
[https://itk.org/ITKExamples[ITK Sphinx Examples]]
void CreateImage(ImageType::Pointer image);
int main(int, char*[])
{
  ImageType::Pointer image = ImageType::New();
  CreateImage(image);
  ImageType::SizeType radius;
  radius.Fill(1);
 
  //typedef itk::FlatStructuringElement<2> StructuringElementType;
  typedef itk::BinaryBallStructuringElement<int, 2> StructuringElementType;
  StructuringElementType::RadiusType elementRadius;
  elementRadius.Fill(3);
 
  StructuringElementType structuringElement;
  structuringElement.SetRadius(elementRadius);
  structuringElement.CreateStructuringElement();
 
  typedef itk::ShapedNeighborhoodIterator<ImageType> IteratorType;
  IteratorType iterator(structuringElement.GetRadius(), image, image->GetLargestPossibleRegion());
 
  iterator.SetNeighborhood(structuringElement);
 
  return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
  ImageType::IndexType start;
  start.Fill(0);
  ImageType::SizeType size;
  size.Fill(10);
 
  ImageType::RegionType region(start,size);
 
  image->SetRegions(region);
  image->Allocate();
  image->FillBuffer(0);
}
</source>
 
{{ITKCMakeLists|ShapedNeighborhoodIterator}}

Latest revision as of 15:56, 31 May 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.

[ITK Sphinx Examples]