1 #include "gdcmDocument.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 // We assume that DICOM fields of second file actually exists :
25 std::string nbFrames = f2->GetHeader()->GetEntryByNumber(0x0028, 0x0008);
26 if(nbFrames != "gdcm::Unfound") {
27 f1->GetHeader()->ReplaceOrCreateByNumber( nbFrames, 0x0028, 0x0008);
30 f1->GetHeader()->ReplaceOrCreateByNumber(
31 f2->GetHeader()->GetEntryByNumber(0x0028, 0x0010), 0x0028, 0x0010); // nbLig
32 f1->GetHeader()->ReplaceOrCreateByNumber(
33 f2->GetHeader()->GetEntryByNumber(0x0028, 0x0011), 0x0028, 0x0011); // nbCol
35 // Some other tags should be updated:
37 // TODO : add a default value
38 // TODO : a function which take as input a list of tuple (gr, el)
39 // and that does the job
41 int dataSize = f2->GetImageDataSize();
42 void *imageData = f2->GetImageData();
44 std::cout << "dataSize :" << dataSize << std::endl;
46 // TODO : Shouldn't we merge those two functions ?
47 f1->SetImageData( imageData, dataSize);
48 f1->GetHeader()->SetImageDataSize( dataSize );
50 f1->GetHeader()->Print();
52 std::string s0 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0000);
53 std::string s10 = f2->GetHeader()->GetEntryByNumber(0x7fe0, 0x0010);
55 std::cout << "lgr 7fe0, 0000 " << s0 << std::endl;
56 std::cout << "lgr 7fe0, 0010 " << s10 << std::endl;
58 std::cout << "WriteDCM" << std::endl;
60 f1->WriteDcmExplVR("WriteDicom.dcm");