X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FexAnonymize.cxx;h=d0672dda64f70869a0d41ac630b0bab582aa6676;hb=4695af60407895e5f0851ffcb9afdb138c9870f7;hp=baca6d7add4857458d0a22f59a206060a7f4233a;hpb=930f45b89f9fc8543609add0950663aa4005a7b5;p=gdcm.git diff --git a/Example/exAnonymize.cxx b/Example/exAnonymize.cxx index baca6d7a..d0672dda 100644 --- a/Example/exAnonymize.cxx +++ b/Example/exAnonymize.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exAnonymize.cxx,v $ Language: C++ - Date: $Date: 2005/02/08 17:58:21 $ - Version: $Revision: 1.2 $ + Date: $Date: 2005/07/07 17:31:53 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,13 +23,11 @@ #include int main(int argc, char *argv[]) -{ - gdcm::File *f1; - +{ gdcm::Debug::DebugOn(); std::cout << "------------------------------------------------" << std::endl; std::cout << "Anonymize a full gdcm-readable Dicom image" << std::endl; - std::cout << " Warning : probabely segfaults if pixels are not " + std::cout << " Warning : probably segfaults if pixels are not " << " gdcm readable. Use exAnonymizeNoLoad" << std::endl; if( argc < 3 ) @@ -48,8 +46,12 @@ int main(int argc, char *argv[]) std::cout << argv[1] << std::endl; - f1 = new gdcm::File( fileName ); - if (!f1->IsReadable()) { + gdcm::File *f = new gdcm::File(); + f->SetLoadMode( 0x00000000); + f->SetFileName( fileName ); + bool res = f->Load(); + + if (!res) { std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <GetImageData(); + uint8_t *imageData = fh->GetImageData(); if ( imageData == 0 ) { @@ -82,35 +84,35 @@ int main(int argc, char *argv[]) // Choose the fields to anonymize. // ============================================================ // Institution name - f1->AddAnonymizeElement(0x0008, 0x0080, "Xanadoo"); + f->AddAnonymizeElement(0x0008, 0x0080, "Xanadoo"); // Patient's name - f1->AddAnonymizeElement(0x0010, 0x0010, "Fantomas"); + f->AddAnonymizeElement(0x0010, 0x0010, "Fantomas"); // Patient's ID - f1->AddAnonymizeElement( 0x0010, 0x0020,"1515" ); + f->AddAnonymizeElement( 0x0010, 0x0020,"1515" ); // Study Instance UID - f1->AddAnonymizeElement(0x0020, 0x000d, "9.99.999.9999" ); + f->AddAnonymizeElement(0x0020, 0x000d, "9.99.999.9999" ); // Telephone - f1->AddAnonymizeElement(0x0010, 0x2154, "3615" ); + f->AddAnonymizeElement(0x0010, 0x2154, "3615" ); // Aware use will add new fields here // The gdcm::File is modified in memory - f1->AnonymizeFile(); + f->AnonymizeFile(); // ============================================================ // Write a new file // ============================================================ - fh1->WriteDcmExplVR(outputFileName); + fh->WriteDcmExplVR(outputFileName); std::cout <<"End Anonymize" << std::cout; // ============================================================ // Remove the Anonymize list // ============================================================ - f1->ClearAnonymizeList(); + f->ClearAnonymizeList(); - delete f1; - delete fh1; + delete f; + delete fh; return 0; }