#include <list>
#include <fstream>
int main(int argc, char* argv[])
{
if( argc < 5 )
{
std::cerr << "Usage: " << argv[0] << " DicomImage OutputDicomImage Entry Value\n";
return EXIT_FAILURE;
}
typedef signed short InputPixelType;
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;
return EXIT_FAILURE;
}
InputImageType::Pointer inputImage = reader->GetOutput();
DictionaryType & dictionary = inputImage->GetMetaDataDictionary();
for (int i = 3; i < argc; i+=2)
{
std::string entryId( argv[i] );
std::string value( argv[i+1] );
itk::EncapsulateMetaData<std::string>( dictionary, entryId, value );
}
Writer1Type::Pointer writer1 = Writer1Type::New();
writer1->SetInput( reader->GetOutput() );
writer1->SetFileName( argv[2] );
writer1->SetImageIO( gdcmImageIO );
try
{
writer1->Update();
}
{
std::cerr << "exception in file writer " << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}