#include <vector>
#include "itksys/SystemTools.hxx"
int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << argv[0];
std::cerr << " InputImage OutputDicomDirectory" << std::endl;
return EXIT_FAILURE;
}
using PixelType = short;
reader->SetFileName(argv[1]);
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;
std::string tagkey = "0008|0060";
std::string value = "MR";
itk::EncapsulateMetaData<std::string>(dict, tagkey, value);
tagkey = "0008|0008";
value = "DERIVED\\SECONDARY";
itk::EncapsulateMetaData<std::string>(dict, tagkey, value);
tagkey = "0008|0064";
value = "DV";
itk::EncapsulateMetaData<std::string>(dict, tagkey, value);
seriesWriter->SetInput(reader->GetOutput());
seriesWriter->SetImageIO(gdcmIO);
reader->GetOutput()->GetLargestPossibleRegion();
std::string format = outputDirectory;
format += "/image%03d.dcm";
namesGenerator->SetSeriesFormat(format.c_str());
namesGenerator->SetStartIndex(start[2]);
namesGenerator->SetEndIndex(start[2] + size[2] - 1);
namesGenerator->SetIncrementIndex(1);
seriesWriter->SetFileNames(namesGenerator->GetFileNames());
try
{
seriesWriter->Update();
}
{
std::cerr << "Exception thrown while writing the series " << std::endl;
std::cerr << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}