]> Creatis software - gdcm.git/commitdiff
exAnonymizeNoLoad can now anonymize any kind of document (even if they are not
authorjpr <jpr>
Wed, 27 Apr 2005 12:40:28 +0000 (12:40 +0000)
committerjpr <jpr>
Wed, 27 Apr 2005 12:40:28 +0000 (12:40 +0000)
File::Readable - Document::Readable is enough-)

Example/exAnonymizeNoLoad.cxx

index 2b55850c560514e1b2ee8b85b22e7c2ca7a7941f..0417a74e48e657b011457fdcd8a863196a75c5b5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: exAnonymizeNoLoad.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/04/26 16:21:55 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2005/04/27 12:40:28 $
+  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
 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 "
+   std::cout << "        : to preserve image integrity,"
              << " use exAnonymize "                                << std::endl;
+   std::cout << "------------------------------------------------" << std::endl;
  
-   if( argc < 3 )
+   if( argc < 2 )
     {
-    std::cerr << "Usage " << argv[0] << " Source image.dcm  " 
+    std::cerr << "Usage " << argv[0] << " Source Document  " 
               << std::endl;
     return 1;
     }
@@ -47,15 +48,18 @@ int main(int argc, char *argv[])
 //   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"
-                 <<std::endl;
+   f1 = new gdcm::File( );
+   f1->SetLoadMode(NO_SEQ - NO_SHADOW);
+   f1->Load(fileName);
+   // We want to process any kind of gdcm::Readable document
+   if (!f1->gdcm::Document::IsReadable()) {
+       std::cout <<std::endl
+           << "Sorry, " << fileName <<"  not a gdcm-readable "
+           << "DICOM / ACR Document"
+           <<std::endl;
+        return 1;
    }
-   std::cout << " ... is readable " << std::endl;
+   std::cout << argv[1] << " is readable " << std::endl;
 
 // ============================================================
 //   No need to load the pixels in memory.
@@ -67,13 +71,19 @@ int main(int argc, char *argv[])
 //  Choose the fields to anonymize.
 // ============================================================
    // Institution name 
-   f1->AddAnonymizeElement(0x0008, 0x0080, "Xanadoo"); 
+   f1->AddAnonymizeElement( 0x0008, 0x0080, "Xanadoo" ); 
    // Patient's name 
-   f1->AddAnonymizeElement(0x0010, 0x0010, "Fantomas");   
+   f1->AddAnonymizeElement( 0x0010, 0x0010, "Fantomas" );   
    // Patient's ID
-   f1->AddAnonymizeElement( 0x0010, 0x0020,"1515" );   
+   f1->AddAnonymizeElement( 0x0010, 0x0020,"1515" );
+   // Patient's Birthdate
+   f1->AddAnonymizeElement( 0x0010, 0x0030,"11.11.1111" );
+   // Patient's Adress
+   f1->AddAnonymizeElement( 0x0010, 0x1040,"Sing-sing" );
+   // Patient's Mother's Birth Name
+   f1->AddAnonymizeElement( 0x0010, 0x1060,"Vampirella" );   
    // Study Instance UID
-   f1->AddAnonymizeElement(0x0020, 0x000d, "9.99.999.9999" );
+   f1->AddAnonymizeElement( 0x0020, 0x000d, "9.99.999.9999" );
    // Telephone
    f1->AddAnonymizeElement(0x0010, 0x2154, "3615" );
   // Aware use will add new fields here