typedef ImageType::PixelType PixelType;
static void CreateImage(ImageType::Pointer image);
int main(int, char*[])
{
ImageType::Pointer image = ImageType::New();
CreateImage(image);
StructuringElementType;
StructuringElementType::RadiusType elementRadius;
elementRadius.Fill(2);
StructuringElementType structuringElement;
structuringElement.CreateStructuringElement();
IteratorType siterator(structuringElement.GetRadius(),
image,
image->GetLargestPossibleRegion());
siterator.NeedToUseBoundaryConditionOff();
IteratorType::IndexType location;
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)
{
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);
}