void CreateImage(ImageType::Pointer image);
int main(int, char*[])
{
ImageType::Pointer image = ImageType::New();
CreateImage(image);
IteratorType iterator(radius, image, image->GetLargestPossibleRegion());
std::cout << "By default there are " << iterator.GetActiveIndexListSize() << " active indices." << std::endl;
IteratorType::OffsetType top = {{0,-1}};
iterator.ActivateOffset(top);
IteratorType::OffsetType bottom = {{0,1}};
iterator.ActivateOffset(bottom);
std::cout << "Now there are " << iterator.GetActiveIndexListSize() << " active indices." << std::endl;
IteratorType::IndexListType indexList = iterator.GetActiveIndexList();
IteratorType::IndexListType::const_iterator listIterator = indexList.begin();
while (listIterator != indexList.end())
{
std::cout << *listIterator << " ";
++listIterator;
}
std::cout << std::endl;
for(iterator.GoToBegin(); !iterator.IsAtEnd(); ++iterator)
{
std::cout << "New position: " << std::endl;
IteratorType::ConstIterator ci = iterator.Begin();
while (! ci.IsAtEnd())
{
std::cout << "Centered at " << iterator.GetIndex() << std::endl;
std::cout << "Neighborhood index " << ci.GetNeighborhoodIndex()
<< " is offset " << ci.GetNeighborhoodOffset()
<< " and has value " << ci.Get()
<< " The real index is " << iterator.GetIndex() + ci.GetNeighborhoodOffset() << std::endl;
ci++;
}
}
std::cout << std::endl;
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
}