1 /*=========================================================================
4 Module: $RCSfile: exAnonymizeNoLoad.cxx,v $
6 Date: $Date: 2005/04/26 16:21:55 $
7 Version: $Revision: 1.3 $
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"
21 #include "gdcmDebug.h"
25 int main(int argc, char *argv[])
29 gdcm::Debug::DebugOn();
30 std::cout << "------------------------------------------------" << std::endl;
31 std::cout << "Anonymize a gdcm-readable Dicom image" << std::endl;
32 std::cout << "even if pixels are not gdcm readable (JPEG2000)" << std::endl;
33 std::cout << "Warning : the image is overwritten" << std::endl;
34 std::cout << " : to preserve image integrity "
35 << " use exAnonymize " << std::endl;
39 std::cerr << "Usage " << argv[0] << " Source image.dcm "
44 std::string fileName = argv[1];
46 // ============================================================
47 // Read the input image.
48 // ============================================================
50 std::cout << argv[1] << std::endl;
52 f1 = new gdcm::File( fileName );
53 if (!f1->IsReadable()) {
54 std::cerr << "Sorry, " << fileName <<" not a gdcm-readable "
58 std::cout << " ... is readable " << std::endl;
60 // ============================================================
61 // No need to load the pixels in memory.
62 // File will be overwritten
63 // ============================================================
66 // ============================================================
67 // Choose the fields to anonymize.
68 // ============================================================
70 f1->AddAnonymizeElement(0x0008, 0x0080, "Xanadoo");
72 f1->AddAnonymizeElement(0x0010, 0x0010, "Fantomas");
74 f1->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
76 f1->AddAnonymizeElement(0x0020, 0x000d, "9.99.999.9999" );
78 f1->AddAnonymizeElement(0x0010, 0x2154, "3615" );
79 // Aware use will add new fields here
82 // No need to load the pixels.
85 // ============================================================
87 // ============================================================
89 std::cout <<"Let's AnonymizeNoLoad " << std::endl;;
91 // The gdcm::File remains untouched in memory
93 f1->AnonymizeNoLoad();
95 // No need to write the File : modif were done on disc !
96 // File was overwritten ...
98 std::cout <<"End AnonymizeNoLoad" << std::endl;
100 // ============================================================
101 // Remove the Anonymize list
102 // ============================================================
103 f1->ClearAnonymizeList();