int main( int argc, char ** argv )
{
if( argc < 5 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << "directory regularExression ";
std::cerr << "sortingExpression outputImageFile " << std::endl;
return EXIT_FAILURE;
}
using PixelType = unsigned char;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
std::string directory = argv[1];
std::string regularExpression = argv[2];
const unsigned int subMatch = std::stoi( argv[3] );
std::string outputFilename = argv[4];
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetRegularExpression( regularExpression );
nameGenerator->SetSubMatch( subMatch );
nameGenerator->SetDirectory( directory );
reader->SetFileNames( nameGenerator->GetFileNames() );
writer->SetFileName( outputFilename );
writer->SetInput( reader->GetOutput() );
try
{
writer->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}