int
main(int argc, char * argv[])
{
if (argc < 6)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile ";
std::cerr << " outputImageFileErosion outputImageFileDilation";
std::cerr << " lowerThreshold upperThreshold " << std::endl;
return EXIT_FAILURE;
}
using InputPixelType = unsigned char;
using OutputPixelType = unsigned char;
using ThresholdFilterType =
using StructuringElementType =
OutputImageType,
StructuringElementType>;
using DilateFilterType =
OutputImageType,
StructuringElementType>;
StructuringElementType structuringElement;
structuringElement.CreateStructuringElement();
binaryErode->SetKernel(structuringElement);
binaryDilate->SetKernel(structuringElement);
reader->SetFileName(argv[1]);
writerErosion->SetFileName(argv[2]);
writerDilation->SetFileName(argv[3]);
const InputPixelType lowerThreshold = std::stoi(argv[4]);
const InputPixelType upperThreshold = std::stoi(argv[5]);
thresholder->SetInput(reader->GetOutput());
InputPixelType background = 0;
InputPixelType foreground = 255;
thresholder->SetOutsideValue(background);
thresholder->SetInsideValue(foreground);
thresholder->SetLowerThreshold(lowerThreshold);
thresholder->SetUpperThreshold(upperThreshold);
binaryErode->SetInput(thresholder->GetOutput());
binaryDilate->SetInput(thresholder->GetOutput());
binaryErode->SetErodeValue(foreground);
binaryDilate->SetDilateValue(foreground);
writerDilation->SetInput(binaryDilate->GetOutput());
writerDilation->Update();
writerErosion->SetInput(binaryErode->GetOutput());
writerErosion->Update();
return EXIT_SUCCESS;
}