int
main(int argc, char * argv[])
{
if (argc != 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0];
std::cerr << " <InputFileName> <OutputFileName>";
std::cerr << std::endl;
return EXIT_FAILURE;
}
const char * inputFileName = argv[1];
const char * outputFileName = argv[2];
std::string format = std::string(outputFileName) + std::string("-%d.png");
using PixelType = unsigned char;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(inputFileName);
using OutputPixelType = unsigned char;
RescaleFilterType::Pointer rescale = RescaleFilterType::New();
rescale->SetInput(reader->GetOutput());
rescale->SetOutputMinimum(0);
rescale->SetOutputMaximum(255);
rescale->UpdateLargestPossibleRegion();
fnames->SetStartIndex(0);
fnames->SetEndIndex(size[2] - 1);
fnames->SetIncrementIndex(1);
fnames->SetSeriesFormat(format.c_str());
WriterType::Pointer writer = WriterType::New();
writer->SetInput(rescale->GetOutput());
writer->SetFileNames(fnames->GetFileNames());
try
{
writer->Update();
}
catch (itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}