#include <list>
#include <fstream>
int
main(int argc, char * argv[])
{
if (argc < 5)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " DicomImage OutputDicomImage ";
std::cerr << " OutputImage RescaleDicomImage\n";
return EXIT_FAILURE;
}
using InputPixelType = short;
constexpr unsigned int InputDimension = 2;
reader->SetFileName(argv[1]);
reader->SetImageIO(gdcmImageIO);
try
{
reader->Update();
}
catch (
const itk::ExceptionObject &
e)
{
std::cerr << "exception in file reader " << std::endl;
std::cerr <<
e << std::endl;
return EXIT_FAILURE;
}
writer1->SetFileName(argv[2]);
writer1->SetInput(reader->GetOutput());
writer1->SetImageIO(gdcmImageIO);
try
{
writer1->Update();
}
catch (
const itk::ExceptionObject &
e)
{
std::cerr << "exception in file writer " << std::endl;
std::cerr <<
e << std::endl;
return EXIT_FAILURE;
}
using WritePixelType = unsigned char;
using RescaleFilterType =
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
writer2->SetFileName(argv[3]);
rescaler->SetInput(reader->GetOutput());
writer2->SetInput(rescaler->GetOutput());
try
{
writer2->Update();
}
catch (
const itk::ExceptionObject &
e)
{
std::cerr << "exception in file writer " << std::endl;
std::cerr <<
e << std::endl;
return EXIT_FAILURE;
}
writer3->SetFileName(argv[4]);
writer3->SetInput(rescaler->GetOutput());
writer3->UseInputMetaDataDictionaryOff();
writer3->SetImageIO(gdcmImageIO);
try
{
writer3->Update();
}
catch (
const itk::ExceptionObject &
e)
{
std::cerr << "Exception in file writer " << std::endl;
std::cerr <<
e << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}