#include <vector>
#include "itksys/SystemTools.hxx"
int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << argv[0]
<< " DicomDirectory OutputDicomDirectory" << std::endl;
return EXIT_FAILURE;
}
using PixelType = short;
namesGenerator->SetInputDirectory(argv[1]);
const ReaderType::FileNamesContainer & filenames =
namesGenerator->GetInputFileNames();
const size_t numberOfFileNames = filenames.size();
std::cout << numberOfFileNames << std::endl;
for (unsigned int fni = 0; fni < numberOfFileNames; ++fni)
{
std::cout << "filename # " << fni << " = ";
std::cout << filenames[fni] << std::endl;
}
reader->SetImageIO(gdcmIO);
reader->SetFileNames(filenames);
try
{
reader->Update();
}
{
std::cerr << "Exception thrown while writing the image" << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
const char * outputDirectory = argv[2];
itksys::SystemTools::MakeDirectory(outputDirectory);
using OutputPixelType = short;
constexpr unsigned int OutputDimension = 2;
seriesWriter->SetInput(reader->GetOutput());
seriesWriter->SetImageIO(gdcmIO);
namesGenerator->SetOutputDirectory(outputDirectory);
seriesWriter->SetFileNames(namesGenerator->GetOutputFileNames());
seriesWriter->SetMetaDataDictionaryArray(
reader->GetMetaDataDictionaryArray());
try
{
seriesWriter->Update();
}
{
std::cerr << "Exception thrown while writing the series " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}