From 2d217e8646ae1df5d733a87fa0daa3fb6c07bf5f Mon Sep 17 00:00:00 2001 From: jpr Date: Wed, 12 Sep 2007 10:49:40 +0000 Subject: [PATCH] Fix misstyping --- Example/ExtractOverlays.cxx | 222 ------------------------------------ Example/exExtractCSA.cxx | 6 +- 2 files changed, 3 insertions(+), 225 deletions(-) delete mode 100755 Example/ExtractOverlays.cxx diff --git a/Example/ExtractOverlays.cxx b/Example/ExtractOverlays.cxx deleted file mode 100755 index 162939f4..00000000 --- a/Example/ExtractOverlays.cxx +++ /dev/null @@ -1,222 +0,0 @@ -/*========================================================================= - - Program: gdcm - Module: $RCSfile: ExtractOverlays.cxx,v $ - Language: C++ - Date: $Date: 2007/05/23 14:18:04 $ - Version: $Revision: 1.3 $ - - 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 "gdcmDataEntry.h" -#include "gdcmDirList.h" - -#include "gdcmArgMgr.h" -#include - -// Each BIT of Overlay Data (0x6000,0x3000) corresponds -// to a BYTE of overlay image. -void explodeByte(unsigned char byte, unsigned char* result) -{ - unsigned char mask = 1; - for (int i=0;i<8;i++) - { - if ((byte & mask)==0) - result[i]=0; - else - result[i]=1; - mask<<=1; - } - return; -} - - -int main(int argc, char *argv[]) -{ - START_USAGE(usage) - " \n ExtractOverlays :\n ", - " Extract overlay images from all DICOM image within a directory ", - " Warning : probably segfaults if no overlay ", - " usage: ExtractOverlays dirin=inputDirectoryName [debug] ", - " debug : developper wants to run the program in 'debug mode' ", - FINISH_USAGE - - // ----- Initialize Arguments Manager ------ - - GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv); - - if (argc == 1 || am->ArgMgrDefined("usage")) - { - am->ArgMgrUsage(usage); // Display 'usage' - delete am; - return 0; - } - - const char *dirIn = am->ArgMgrWantString("dirin", usage); - - if (am->ArgMgrDefined("debug")) - GDCM_NAME_SPACE::Debug::DebugOn(); - - if (am->ArgMgrDefined("warning")) - GDCM_NAME_SPACE::Debug::WarningOn(); - - // if unused Param we give up - if ( am->ArgMgrPrintUnusedLabels() ) - { - am->ArgMgrUsage(usage); - delete am; - return 0; - } - - delete am; // we don't need Argument Manager any longer - - - // ========================== Now, we can do the job! ================ - - - // ======================== more checking on the params ============== - - if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(dirIn) ) - { - std::cout << "KO : [" << dirIn << "] is not a Directory." << std::endl; - return 0; - - } - - char outputFileName[1024]; // Hope it's enough for a file name! - - GDCM_NAME_SPACE::File *f; - - GDCM_NAME_SPACE::DirList dirList(dirIn,true); // gets (recursively) the file list - GDCM_NAME_SPACE::DirListType fileList = dirList.GetFilenames(); - for( GDCM_NAME_SPACE::DirListType::iterator it = fileList.begin(); - it != fileList.end(); - ++it ) - { - // Just to see *all* the file names: - // std::cout << "file [" << it->c_str() << "]" << std::endl; - - // Read the input file. - - f = GDCM_NAME_SPACE::File::New( ); - f->SetLoadMode( GDCM_NAME_SPACE::LD_ALL ); - f->SetFileName( it->c_str() ); - - f->AddForceLoadElement(0x6000,0x3000); // Overlay Data - f->AddForceLoadElement(0x6002,0x3000); - f->AddForceLoadElement(0x6004,0x3000); - f->AddForceLoadElement(0x6006,0x3000); - f->AddForceLoadElement(0x6008,0x3000); - f->AddForceLoadElement(0x600a,0x3000); - f->AddForceLoadElement(0x600c,0x3000); - f->AddForceLoadElement(0x600e,0x3000); - - int res = f->Load(); - - if ( !res ) - { - std::cerr << "Sorry, " << it->c_str() <<" not a gdcm-readable " - << "DICOM / ACR File" <Delete(); - continue; - } - std::cout << " ... is readable " << std::endl; - - // ============================================================ - // Load the Overlays in memory (the first one) - // ============================================================ - -/// \todo : deal with *each* overlay Data Element (not only the first one!) - - uint16_t ovlyGroup = 0x6000; - - GDCM_NAME_SPACE::DataEntry *e = f->GetDataEntry(ovlyGroup, 0x3000); - if (e == 0) - { - std::cout << " Image doesn't contain any Overlay " << std::endl; - f->Delete(); - continue; - } - std::cout << " File is read! " << std::endl; - - uint8_t *overlay = (uint8_t *)(e->GetBinArea()); - if ( overlay == 0 ) - { - std::cerr << "Sorry, Overlays of" << it->c_str() <<" are not " - << " gdcm-readable." << std::endl; - f->Delete(); - continue; - } - - // ============================================================ - // Image data generation. - // ============================================================ - - unsigned int dimX= f->GetXSize(); - unsigned int dimY= f->GetYSize(); - - unsigned int dimXY=dimX*dimY; - std::cout << "DimX : "<< dimX <<" DimY : " << dimY - << " DimXY : " <InsertEntryString(temp,0x0028,0x0011, "US"); // Columns - sprintf(temp,"%d ",dimY); - f2->InsertEntryString(temp,0x0028,0x0010, "US"); // Rows - - f2->InsertEntryString("8",0x0028,0x0100, "US"); // Bits Allocated - f2->InsertEntryString("8",0x0028,0x0101, "US"); // Bits Stored - f2->InsertEntryString("7",0x0028,0x0102, "US"); // High Bit - f2->InsertEntryString("0",0x0028,0x0103, "US"); // Pixel Representation - f2->InsertEntryString("1",0x0028,0x0002, "US"); // Samples per Pixel - f2->InsertEntryString("MONOCHROME2 ",0x0028,0x0004, "LO"); - - sprintf(outputFileName, "%s.ovly.dcm",it->c_str() ); - - // feel free to add any field (Dicom Data Entry) you like, here. - // ... - GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f2); - - fh->SetImageData(outputData,dimXY); - fh->WriteDcmExplVR(outputFileName); - std::cout <<"End WriteOverlayImage" << std::endl; - - delete outputData; - f->Delete(); - f2->Delete(); - fh->Delete(); - -} // end of loop on files - - return 0; -} - diff --git a/Example/exExtractCSA.cxx b/Example/exExtractCSA.cxx index bb118b78..732a597b 100755 --- a/Example/exExtractCSA.cxx +++ b/Example/exExtractCSA.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exExtractCSA.cxx,v $ Language: C++ - Date: $Date: 2007/09/11 12:56:11 $ - Version: $Revision: 1.6 $ + Date: $Date: 2007/09/12 10:49:40 $ + Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -125,7 +125,7 @@ bool check_mapping(uint32_t syngodt, const char *vr) } - ///\to fix the Desctructor! + ///\to fix the Destructor! void DeleteCSA_content (CSA_content &myMap) { for ( CSA_content::const_iterator it = myMap.begin(); it != myMap.end(); -- 2.45.0