namespace
{
using PixelType = ImageType::PixelType;
}
static void CreateImage(ImageType::Pointer image);
int main(int, char*[])
{
ImageType::Pointer image = ImageType::New();
CreateImage(image);
StructuringElementType::RadiusType elementRadius;
elementRadius.Fill(2);
StructuringElementType structuringElement;
structuringElement.CreateStructuringElement();
IteratorType siterator(structuringElement.GetRadius(),
image,
image->GetLargestPossibleRegion());
siterator.NeedToUseBoundaryConditionOff();
location[0] = 4;
location[1] = 5;
siterator.SetLocation(location);
IteratorType::Iterator i;
for (i = siterator.Begin(); !i.IsAtEnd(); ++i)
{
i.Set(1);
}
ImageIteratorType imit(image, image->GetLargestPossibleRegion());
unsigned int col = 0;
while( !imit.IsAtEnd() )
{
PixelType value = imit.Get();
++imit;
++col;
std::cout << value << " ";
if ((col % 10) == 0)
{
std::cout << std::endl;
}
}
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
}