5 int main(int argc, char* argv[])
13 //gdcmDocument * d; //not used
18 std::cerr << "usage: " << std::endl
19 << argv[0] << " fileName writtingMode "
21 << "(a : ACR, d : DICOM Implicit VR,"
22 << " x : DICOM Explicit VR, r : RAW)"
27 if (0) { // Just to keep the code for further use
28 std::cout <<std::endl << "-------- Test gdcmHeader ------" <<std::endl;
29 e1 = new gdcmHeaderHelper(argv[1]);
30 if (!f1->GetHeader()->IsReadable()) {
31 std::cout << "Sorry, not a DICOM / ACR File" <<std::endl;
34 std::cout << std::endl << "----------------------> after new gdcmHeader"
37 std::cout <<std::endl <<"---------------------------------------"
42 std::cout << std::endl
43 << "--------------------- file :" << argv[1]
48 e1 = new gdcm::Header( toto.c_str() );
49 if (!e1->IsReadable()) {
50 std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
55 f1 = new gdcm::File(e1);
58 dataSize = f1->GetImageDataSize();
59 std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
60 int nX,nY,nZ,sPP,planarConfig;
61 std::string pixelType, transferSyntaxName;
65 std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
67 pixelType = e1->GetPixelType();
68 sPP = e1->GetSamplesPerPixel();
69 planarConfig = e1->GetPlanarConfiguration();
71 std::cout << " pixelType=" << pixelType
72 << " SampleserPixel=" << sPP
73 << " PlanarConfiguration=" << planarConfig
74 << " PhotometricInterpretation="
75 << e1->GetEntryByNumber(0x0028,0x0004)
78 int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
79 std::cout << "NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
80 transferSyntaxName = e1->GetTransfertSyntaxName();
81 std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
83 if ( transferSyntaxName != "Implicit VR - Little Endian"
84 && transferSyntaxName != "Explicit VR - Little Endian"
85 && transferSyntaxName != "Deflated Explicit VR - Little Endian"
86 && transferSyntaxName != "Explicit VR - Big Endian"
87 && transferSyntaxName != "Uncompressed ACR-NEMA" ) {
88 std::cout << std::endl << "==========================================="
90 f1->GetPixelConverter()->Print();
91 std::cout << std::endl << "==========================================="
94 imageData= f1->GetImageData();
98 // ecriture d'un fichier ACR
99 // à partir d'un dcmHeader correct.
101 sprintf(zozo, "%s.ACR", toto.c_str());
102 printf ("WriteACR\n");
107 // ecriture d'un fichier DICOM Implicit VR
108 // à partir d'un dcmHeader correct.
110 sprintf(zozo, "%s.DCM", toto.c_str());
111 printf ("WriteDCM Implicit VR\n");
112 f1->WriteDcmImplVR(zozo);
116 // ecriture d'un fichier DICOM Explicit VR
117 // à partir d'un dcmHeader correct.
119 sprintf(zozo, "%s.XDCM", toto.c_str());
120 std::cout << "WriteDCM Explicit VR" << std::endl;
121 f1->WriteDcmExplVR(zozo);
125 // Ecriture d'un Raw File, a afficher avec
126 // affim filein= dimx= dimy= nbit= signe=
128 sprintf(zozo, "%s.RAW", toto.c_str());
129 std::cout << "WriteRaw" << std::endl;
130 f1->WriteRawData(zozo);