int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImage outputImageDoublePixelType ";
std::cerr << " outputImage8BitsPixelType [RMS] [numberOfIterations]"
<< std::endl;
return EXIT_FAILURE;
}
const char * inputFilename = argv[1];
const char * outputFilename1 = argv[2];
const char * outputFilename2 = argv[3];
double maximumRMSError = 0.01;
unsigned int numberOfIterations = 50;
if (argc > 4)
{
maximumRMSError = std::stod(argv[4]);
}
if (argc > 5)
{
numberOfIterations = std::stoi(argv[5]);
}
using CharPixelType = unsigned char;
using RealPixelType = double;
using CastToRealFilterType =
using RescaleFilter =
using AntiAliasFilterType =
reader->SetFileName(inputFilename);
rescale->SetOutputMinimum(0);
rescale->SetOutputMaximum(255);
toReal->SetInput(reader->GetOutput());
antiAliasFilter->SetInput(toReal->GetOutput());
antiAliasFilter->SetMaximumRMSError(maximumRMSError);
antiAliasFilter->SetNumberOfIterations(numberOfIterations);
antiAliasFilter->SetNumberOfLayers(2);
realWriter->SetInput(antiAliasFilter->GetOutput());
realWriter->SetFileName(outputFilename1);
try
{
realWriter->Update();
}
catch (const itk::ExceptionObject & err)
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
rescale->SetInput(antiAliasFilter->GetOutput());
rescaledWriter->SetInput(rescale->GetOutput());
rescaledWriter->SetFileName(outputFilename2);
try
{
rescaledWriter->Update();
}
catch (const itk::ExceptionObject & err)
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
std::cout << "Completed in " << antiAliasFilter->GetNumberOfIterations()
<< std::endl;
return EXIT_SUCCESS;
}