1 #include "gdcmHeader.h"
4 // Writting of a DICOM file based on a correct dicom header
5 // and data pixel of another image
7 int main(int argc, char* argv[])
12 std::cerr << "Usage :" << std::endl << argv[0] <<
13 " HeaderFileName DataFileName" << std::endl;
17 const char *first = argv[1];
18 gdcmFile *f1 = new gdcmFile( first );
20 const char *second = argv[2];
21 gdcmFile *f2 = new gdcmFile( second );
23 // f1->PrintPubElVal();
25 // We assume that DICOM fields of second file actually exists :
27 std::string nbFrames = f2->GetHeader()->GetEntryByNumber(0x0028, 0x0008);
28 if(nbFrames != "gdcm::Unfound") {
29 f1->GetHeader()->ReplaceOrCreateByNumber( nbFrames, 0x0028, 0x0008);
32 f1->GetHeader()->ReplaceOrCreateByNumber(
33 f2->GetHeader()->GetEntryByNumber(0x0028, 0x0010), 0x0028, 0x0010); // nbLig
34 f1->GetHeader()->ReplaceOrCreateByNumber(
35 f2->GetHeader()->GetEntryByNumber(0x0028, 0x0011), 0x0028, 0x0011); // nbCol
37 // Some other tags should be updated:
39 // TODO : add a default value
40 // TODO : a function which take as input a list of tuple (gr, el)
41 // and that does the job
43 int dataSize = f2->GetImageDataSize();
44 void *imageData = f2->GetImageData();
46 std::cout << "dataSize :" << dataSize << std::endl;
48 // TODO : Shouldn't we merge those two functions ?
49 f1->SetImageData( imageData, dataSize);
50 f1->GetHeader()->SetImageDataSize( dataSize );
52 f1->GetHeader()->PrintEntry();
54 std::string s0 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0000);
55 std::string s10 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0010);
57 std::cout << "lgr 7fe0, 0000 " << s0 << std::endl;
58 std::cout << "lgr 7fe0, 0010 " << s10 << std::endl;
60 std::cout << "WriteDCM" << std::endl;
62 f1->WriteDcmExplVR("WriteDicom.dcm");
63 //f1->WriteDcmImplVR(resultat);
64 //f1->WriteAcr(resultat);