1 #include "gdcmHeader.h"
4 // This examples read two images (could be the same). Try to modify
5 // Acquisition Matrix and then write the image again
7 int main(int argc, char* argv[])
11 std::cerr << "usage :" << std::endl <<
12 argv[0] << " nomFichierPourEntete nomFichierPourDonnées" <<
17 gdcmHeader *h1 = new gdcmHeader( argv[1] );
18 gdcmFile *f1 = new gdcmFile( h1 );
19 gdcmFile *f2 = new gdcmFile( argv[2] );
21 // 0018 1310 US ACQ Acquisition Matrix
22 gdcmDictEntry *dictEntry =
23 f2->GetHeader()->GetPubDict()->GetDictEntryByName( "Acquisition Matrix" );
24 std::cerr << std::hex << dictEntry->GetGroup() << "," << dictEntry->GetElement() << std::endl;
26 // std::string matrix = f2->GetHeader()->GetEntryByNumber(0x0018, 0x1310);
27 // Or, strictly equivalent (a little bit longer at run-time !):
28 std::string matrix = f2->GetHeader()->GetEntryByName("Acquisition Matrix");
29 if(matrix != "gdcm::Unfound")
31 std::cerr << "Aquisition Matrix:" << matrix << std::endl;
32 f1->GetHeader()->ReplaceOrCreateByNumber( matrix, 0x0018, 0x1310);
34 //f1->GetHeader()->ReplaceOrCreateByNumber( matrix, dictEntry->GetGroup(),
35 // dictEntry->GetElement());
42 f1->WriteDcmExplVR("output-matrix.dcm");