1 /*=========================================================================
4 Module: $RCSfile: exAnonymize.cxx,v $
6 Date: $Date: 2005/02/06 14:56:22 $
7 Version: $Revision: 1.1 $
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 =========================================================================*/
19 #include "gdcmFileHelper.h"
20 #include "gdcmCommon.h"
24 int main(int argc, char *argv[])
31 std::cerr << "Usage " << argv[0] << " Source image.dcm "
32 << " Output image.dcm " << std::endl;
36 std::string fileName = argv[1];
37 std::string outputFileName = argv[2];
39 // --------------------- we read the input image
41 std::cout << argv[1] << std::endl;
43 f1 = new gdcm::File( fileName );
44 if (!f1->IsReadable()) {
45 std::cerr << "Sorry, " << fileName <<" not a Readable DICOM / ACR File"
50 // ============================================================
51 // Don't load the pixels in memory.
53 // ============================================================
55 // First, we set values to replace the ones we want to hide
58 f1->AddAnonymizeElement(0x0010, 0x0010, "Tartempion");
60 f1->AddAnonymizeElement( 0x0010, 0x0020,"007" );
62 f1->AddAnonymizeElement(0x0020, 0x000d, "6.66.666.6666" );
64 // --------------------- we overwrite the file
66 // No need to load the pixels.
67 // The gdcm::File remains untouched in memory
69 f1->AnonymizeNoLoad();
71 // No need to write the File : modif were done on disc !
73 // ============================================================
74 // Load the pixels in memory.
76 // ============================================================
78 // We need a gdcm::FileHelper, since we want to load the pixels
79 gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
81 // --- Don't forget to load the Pixels ...
82 // (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one)
84 //uint8_t *imageData= fh1->GetImageData();
88 f1->AddAnonymizeElement(0x0008, 0x0080, "Xanadoo");
90 f1->AddAnonymizeElement(0x0010, 0x0010, "Fantomas");
92 f1->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
94 f1->AddAnonymizeElement(0x0020, 0x000d, "9.99.999.9999" );
96 f1->AddAnonymizeElement(0x0010, 0x2154, "3615" );
100 fh1->WriteDcmExplVR(outputFileName);
102 //If we reach here everything is fine, return 0 then:
104 f1->ClearAnonymizeList();