int
main(int argc, char * argv[])
{
if (argc != 5)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0];
std::cerr << " <InputFileName> <OutputFileName> <Lower Threshold> <Upper Threshold>";
std::cerr << std::endl;
return EXIT_FAILURE;
}
const char * inputFileName = argv[1];
const char * outputFileName = argv[2];
using PixelType = unsigned char;
const auto input = itk::ReadImage<ImageType>(inputFileName);
auto lowerThreshold = static_cast<PixelType>(std::stoi(argv[3]));
auto upperThreshold = static_cast<PixelType>(std::stoi(argv[4]));
threshold->SetInput(input);
threshold->SetLowerThreshold(lowerThreshold);
threshold->SetUpperThreshold(upperThreshold);
threshold->SetOutsideValue(0);
filter->SetInput(threshold->GetOutput());
filter->SetObjectValue(255);
writer->SetFileName(outputFileName);
writer->SetInput(filter->GetOutput());
try
{
writer->Update();
}
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}