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 = atof( argv[4] );
}
if( argc > 5 )
{
numberOfIterations = atoi( argv[5] );
}
typedef unsigned char CharPixelType;
typedef double RealPixelType;
const unsigned int Dimension = 3;
RealImageType> CastToRealFilterType;
ReaderType::Pointer reader = ReaderType::New();
CastToRealFilterType::Pointer toReal = CastToRealFilterType::New();
RescaleFilter::Pointer rescale = RescaleFilter::New();
AntiAliasFilterType::Pointer antiAliasFilter = AntiAliasFilterType::New();
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 );
RealWriterType::Pointer realWriter = RealWriterType::New();
realWriter->SetInput( antiAliasFilter->GetOutput() );
realWriter->SetFileName( outputFilename1 );
try
{
realWriter->Update();
}
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
WriterType::Pointer rescaledWriter = WriterType::New();
rescale->SetInput( antiAliasFilter->GetOutput() );
rescaledWriter->SetInput( rescale->GetOutput() );
rescaledWriter->SetFileName( outputFilename2 );
try
{
rescaledWriter->Update();
}
{
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;
}