#include <array>
#include <cassert>
#include <numeric>
#include <ios>
namespace
{
template <typename TOffsets>
void
PrintImageNeighborhoodShape(const TOffsets & offsets)
{
std::cout << " ";
for (const OffsetType & offset : offsets)
{
std::cout << offset << ' ';
}
constexpr unsigned int imageSize{ 7 };
image->SetRegions(ImageType::SizeType::Filled(imageSize));
image->Allocate(true);
const auto centerIndex = ImageType::IndexType::Filled(imageSize / 2);
std::iota(shapedImageNeighborhoodRange.
begin(), shapedImageNeighborhoodRange.
end(), 1);
std::cout << "\n\n";
const std::ios_base::fmtflags flags(std::cout.flags());
std::cout << std::hex << std::uppercase;
auto imageBufferIterator = imageBufferRange.
cbegin();
for (unsigned int y{ 0 }; y < imageSize; ++y)
{
std::cout << " ";
for (unsigned int x{ 0 }; x < imageSize; ++x)
{
std::cout << *imageBufferIterator << ' ';
++imageBufferIterator;
}
std::cout << '\n';
}
std::cout.flags(flags);
std::cout << '\n';
}
}
int
main()
{
const std::array<OffsetType, 3> offsets = { { { { 0, -1 } }, { { 0, 1 } }, { { 1, 1 } } } };
std::cout << "Shape of some arbitrary offsets:\n\n";
PrintImageNeighborhoodShape(offsets);
const bool includeCenterPixel = false;
const size_t maximumCityblockDistance = 1;
std::cout << "4-connected neighborhood shape (excluding the center pixel) with maximumCityblockDistance = "
<< maximumCityblockDistance << ":\n\n";
const auto connectedImageNeighborhoodShapeOffsets =
itk::GenerateConnectedImageNeighborhoodShapeOffsets<Dimension, maximumCityblockDistance, includeCenterPixel>();
PrintImageNeighborhoodShape(connectedImageNeighborhoodShapeOffsets);
std::cout << "Rectangular shape of radius " << radius << ":\n\n";
PrintImageNeighborhoodShape(rectangularImageNeighborhoodOffsets);
}