From a6d55011992465c4caf14f8b2eb9b3268b8f144f Mon Sep 17 00:00:00 2001 From: jpr Date: Tue, 8 Feb 2005 18:02:03 +0000 Subject: [PATCH] Hope-to-be fully commented example --- Example/exAnonymizeNoLoad.cxx | 109 ++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 Example/exAnonymizeNoLoad.cxx diff --git a/Example/exAnonymizeNoLoad.cxx b/Example/exAnonymizeNoLoad.cxx new file mode 100644 index 00000000..a5d6bf9c --- /dev/null +++ b/Example/exAnonymizeNoLoad.cxx @@ -0,0 +1,109 @@ +/*========================================================================= + + Program: gdcm + Module: $RCSfile: exAnonymizeNoLoad.cxx,v $ + Language: C++ + Date: $Date: 2005/02/08 18:02:03 $ + Version: $Revision: 1.1 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "gdcmFile.h" +#include "gdcmFileHelper.h" +#include "gdcmCommon.h" +#include "gdcmDebug.h" + +#include + +int main(int argc, char *argv[]) +{ + gdcm::File *f1; + + gdcm::Debug::DebugOn(); + std::cout << "------------------------------------------------" << std::endl; + std::cout << "Anonymize a gdcm-readable Dicom image" << std::endl; + std::cout << "even if pixels are not gdcm readable (JPEG2000)" << std::endl; + std::cout << "Warning : the image is overwritten" << std::endl; + std::cout << " : to preserve image integrity " + << " use exAnonymize " << std::endl; + + if( argc < 3 ) + { + std::cerr << "Usage " << argv[0] << " Source image.dcm " + << " Output image.dcm " << std::endl; + return 1; + } + + std::string fileName = argv[1]; + std::string outputFileName = argv[2]; + +// ============================================================ +// Read the input image. +// ============================================================ + + std::cout << argv[1] << std::endl; + + f1 = new gdcm::File( fileName ); + if (!f1->IsReadable()) { + std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " + << "DICOM / ACR File" + <AddAnonymizeElement(0x0008, 0x0080, "Xanadoo"); + // Patient's name + f1->AddAnonymizeElement(0x0010, 0x0010, "Fantomas"); + // Patient's ID + f1->AddAnonymizeElement( 0x0010, 0x0020,"1515" ); + // Study Instance UID + f1->AddAnonymizeElement(0x0020, 0x000d, "9.99.999.9999" ); + // Telephone + f1->AddAnonymizeElement(0x0010, 0x2154, "3615" ); + // Aware use will add new fields here + + +// No need to load the pixels. + + +// ============================================================ +// Overwrite the file +// ============================================================ + + std::cout <<"Let's AnonymizeNoLoad " << std::endl;; + +// The gdcm::File remains untouched in memory + + f1->AnonymizeNoLoad(); + +// No need to write the File : modif were done on disc ! +// File was overwritten ... + + std::cout <<"End AnonymizeNoLoad" << std::endl; + +// ============================================================ +// Remove the Anonymize list +// ============================================================ + f1->ClearAnonymizeList(); + + delete f1; + return 0; +} + -- 2.48.1