#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;
}
typedef signed short InputPixelType;
const unsigned int InputDimension = 2;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
reader->SetImageIO( gdcmImageIO );
try
{
reader->Update();
}
{
std::cerr << "exception in file reader " << std::endl;
std::cerr << e << std::endl;
return EXIT_FAILURE;
}
Writer1Type::Pointer writer1 = Writer1Type::New();
writer1->SetFileName( argv[2] );
writer1->SetInput( reader->GetOutput() );
writer1->SetImageIO( gdcmImageIO );
try
{
writer1->Update();
}
{
std::cerr << "exception in file writer " << std::endl;
std::cerr << e << std::endl;
return EXIT_FAILURE;
}
typedef unsigned char WritePixelType;
InputImageType, WriteImageType > RescaleFilterType;
RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
rescaler->SetOutputMinimum( 0 );
rescaler->SetOutputMaximum( 255 );
Writer2Type::Pointer writer2 = Writer2Type::New();
writer2->SetFileName( argv[3] );
rescaler->SetInput( reader->GetOutput() );
writer2->SetInput( rescaler->GetOutput() );
try
{
writer2->Update();
}
{
std::cerr << "exception in file writer " << std::endl;
std::cerr << e << std::endl;
return EXIT_FAILURE;
}
Writer3Type::Pointer writer3 = Writer3Type::New();
writer3->SetFileName( argv[4] );
writer3->SetInput( rescaler->GetOutput() );
writer3->UseInputMetaDataDictionaryOff ();
writer3->SetImageIO( gdcmImageIO );
try
{
writer3->Update();
}
{
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}