|
|
(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}}
| |