#ifdef ENABLE_QUICKVIEW
#endif
namespace
{
}
static void
CreateImage(ImageType * const image);
int
main(int argc, char * argv[])
{
unsigned int radius = 5;
std::string outputFilename = "Output.png";
if (argc >= 4)
{
image = itk::ReadImage<ImageType>(argv[1]);
std::stringstream ss(argv[2]);
ss >> radius;
outputFilename = argv[3];
}
else
{
CreateImage(image);
}
std::cout << "Radius: " << radius << std::endl;
StructuringElementType structuringElement;
structuringElement.CreateStructuringElement();
using BinaryMorphologicalClosingImageFilterType =
closingFilter->SetInput(image);
closingFilter->SetKernel(structuringElement);
closingFilter->Update();
diff->SetInput1(closingFilter->GetOutput());
diff->SetInput2(image);
#ifdef ENABLE_QUICKVIEW
std::stringstream desc;
desc << "Original ";
viewer.
AddImage(image.GetPointer(),
true, desc.str());
std::stringstream desc2;
desc2 << "BinaryClosing, radius = " << radius;
viewer.
AddImage(closingFilter->GetOutput(),
true, desc2.str());
std::stringstream desc3;
desc3 << "BinaryClosing - Original";
viewer.
AddImage(diff->GetOutput(),
true, desc3.str());
#endif
return EXIT_SUCCESS;
}
void
CreateImage(ImageType * const image)
{
unsigned int NumRows = 200;
unsigned int NumCols = 300;
size[0] = NumRows;
size[1] = NumCols;
image->SetRegions(region);
image->Allocate(true);
for (unsigned int r = 40; r < 100; ++r)
{
for (unsigned int c = 40; c < 100; ++c)
{
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 50);
}
}
}