int
main(int argc, char * argv[])
{
if (argc < 5)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile variance maxerror"
<< std::endl;
return EXIT_FAILURE;
}
using InputPixelType = double;
using OutputPixelType = double;
using CharPixelType = unsigned char;
using RescaleFilterType =
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
reader->SetFileName(argv[1]);
writer->SetFileName(argv[2]);
using FilterType =
OutputImageType>;
FilterType::Pointer filter = FilterType::New();
filter->SetVariance(std::stod(argv[3]));
filter->SetMaximumError(std::stod(argv[4]));
filter->SetInput(reader->GetOutput());
rescaler->SetInput(filter->GetOutput());
writer->SetInput(rescaler->GetOutput());
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
try
{
writer->Update();
}
catch (const itk::ExceptionObject & excp)
{
std::cerr << excp << std::endl;
}
return EXIT_SUCCESS;
}