1 /*=========================================================================
4 Module: $RCSfile: TestChangeHeader.cxx,v $
6 Date: $Date: 2005/02/02 12:02:33 $
7 Version: $Revision: 1.34 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
18 #include "gdcmHeader.h"
21 // Writting of a DICOM file, using a correct gdcmHeader.
22 // and pixels of an other image
25 int TestChangeHeader(int argc, char *argv[])
29 std::cerr << "usage :" << std::endl <<
30 argv[0] << " FileForHeader FileForPixels" << std::endl;
34 std::string firstArgument = argv[1];
35 gdcmFile *f1 = new gdcmFile(firstArgument);
37 std::string secondArgument = argv[2];
38 gdcmFile *f2 = new gdcmFile(secondArgument);
40 //f1->PrintPubElVal();
42 // We suppose the DICOM Entries of the second file *does* exist !
44 std::string nbFrames = f2->GetHeader()->GetEntryValue(0x0028, 0x0008);
45 if(nbFrames != GDCM_UNFOUND)
47 f1->GetHeader()->Insert( nbFrames, 0x0028, 0x0008);
51 // WARNING : If user tries to 'merge' two mismatching images
52 // e.g. a LUT image and a RGB image
53 // or a compressed and an uncompressed one
54 // or a single frame and a multiframe,
55 // or a '12 Bits Allocated' image and anything else, etc
56 // Probabely TestChangeHeader will fail !
57 // It was not designed as a 'Test' program, but as a utility
58 // provided to 'transform' an image 'Siemens MRI New version' into an image 'Siemens MRI old version'
60 f1->GetHeader()->Insert(
61 f2->GetHeader()->GetEntryValue(0x0028, 0x0010), 0x0028, 0x0010);// nbLig
62 f1->GetHeader()->Insert(
63 f2->GetHeader()->GetEntryValue(0x0028, 0x0011), 0x0028, 0x0011);// nbCol
64 f1->GetHeader()->Insert(
65 f2->GetHeader()->GetEntryValue(0x0028, 0x0100), 0x0028, 0x0100);// BitsAllocated
66 f1->GetHeader()->Insert(
67 f2->GetHeader()->GetEntryValue(0x0028, 0x0101), 0x0028, 0x0101);// BitsStored
68 f1->GetHeader()->Insert(
69 f2->GetHeader()->GetEntryValue(0x0028, 0x0102), 0x0028, 0x0102);// HighBit
70 f1->GetHeader()->Insert(
71 f2->GetHeader()->GetEntryValue(0x0028, 0x0103), 0x0028, 0x0103);// Pixel Representation
72 // Probabely some more to update (?)
74 // TODO : add a default value
75 // TODO : add a method that receives a list of pairs (gr,el),
76 // and that does the work.
78 int dataSize = f2->GetImageDataSize();
79 printf ("dataSize %d\n",dataSize);
80 uint8_t *imageData= f2->GetImageData();
82 // TODO : Why don't we merge these 2 functions ?
84 f1->SetImageData(imageData,dataSize);
86 f1->GetHeader()->Print();
88 std::string s0 =f2->GetHeader()->GetEntryValue(0x7fe0, 0x0000);
89 std::string s10=f2->GetHeader()->GetEntryValue(0x7fe0, 0x0010);
90 printf("lgr 7fe0, 0000 %s\n",s0.c_str());
91 printf("lgr 7fe0, 0010 %s\n",s10.c_str());
95 sprintf(resultat, "%s.vol", deuxieme.c_str());
96 printf ("WriteDCM\n");
97 //f1->WriteDcmExplVR("itk-gdcm-ex.dcm");
98 //f1->WriteDcmImplVR(resultat);
99 f1->WriteAcr(resultat);