New 'gdcm2' style.
Program: gdcm
Module: $RCSfile: Anonymize.cxx,v $
Language: C++
- Date: $Date: 2005/06/07 11:12:10 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/07/07 17:31:53 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// Read the input file.
// ============================================================
- gdcm::File *f1;
+ gdcm::File *f;
- f1 = new gdcm::File( fileName );
- if (!f1->IsReadable())
+ f = new gdcm::File( );
+ f->SetLoadMode( 0x00000000 );
+ f->SetFileName( fileName );
+ int res = f->Load();
+
+ if ( !res )
{
std::cerr << "Sorry, " << fileName <<" not a gdcm-readable "
<< "DICOM / ACR File" <<std::endl;
- delete f1;
+ delete f;
return 0;
}
std::cout << " ... is readable " << std::endl;
// ============================================================
// We need a gdcm::FileHelper, since we want to load the pixels
- gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
// (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one)
- uint8_t *imageData = fh1->GetImageData();
+ uint8_t *imageData = fh->GetImageData();
if ( imageData == 0 )
{
std::cerr << "Sorry, Pixels of" << fileName <<" are not "
<< " gdcm-readable." << std::endl
<< "Use exAnonymizeNoLoad" << std::endl;
- delete f1;
- delete fh1;
+ delete f;
+ delete fh;
return 0;
}
// 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 user will add more fields to anonymize 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;
}
Program: gdcm
Module: $RCSfile: AnonymizeDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/06/07 14:41:47 $
- Version: $Revision: 1.3 $
+ 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
// Read the input DICOMDIR
// ============================================================
- gdcm::File *f1 = new gdcm::File( fileName );
- if (!f1->IsReadable()) {
+ gdcm::File *f;
+ f = new gdcm::File( );
+ f->SetLoadMode(0);
+ f->SetFileName( fileName );
+ bool res = f->Load();
+ if ( !res )
+ {
std::cerr << "Sorry, " << fileName <<" not a gdcm-readable "
<< "file" <<std::endl;
}
std::cout << " ... is readable " << std::endl;
// Directory record sequence
- gdcm::DocEntry *e = f1->GetDocEntry(0x0004, 0x1220);
+ gdcm::DocEntry *e = f->GetDocEntry(0x0004, 0x1220);
if ( !e )
{
std::cout << "No Directory Record Sequence (0004,1220) found" <<std::endl;;
- delete f1;
+ delete f;
delete e;
return 0;
}
if ( !s )
{
std::cout << "Element (0004,1220) is not a Sequence ?!?" <<std::endl;
- delete f1;
+ delete f;
delete e;
return 0;
}
delete fp;
delete e;
- delete f1;
+ delete f;
return 0;
}
Program: gdcm
Module: $RCSfile: AnonymizeNoLoad.cxx,v $
Language: C++
- Date: $Date: 2005/06/14 09:09:50 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/07/07 17:31:53 $
+ 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
// Parse the input file.
// ============================================================
- gdcm::File *f1;
- f1 = new gdcm::File( );
- f1->SetLoadMode(loadMode);
- int res = f1->Load(fileName);
+ gdcm::File *f;
+ f = new gdcm::File( );
+ f->SetLoadMode(loadMode);
+ f->SetFileName( fileName );
+ bool res = f->Load();
// gdcm::File::IsReadable() is no usable here, because we deal with
// any kind of gdcm::Readable *document*
<< "Sorry, " << fileName <<" not a gdcm-readable "
<< "DICOM / ACR Document"
<< std::endl;
- delete f1;
+ delete f;
return 1;
}
std::cout << fileName << " is readable " << std::endl;
// 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" );
// Patient's Birthdate
- f1->AddAnonymizeElement( 0x0010, 0x0030,"11.11.1111" );
+ f->AddAnonymizeElement( 0x0010, 0x0030,"11.11.1111" );
// Patient's Adress
- f1->AddAnonymizeElement( 0x0010, 0x1040,"Sing-sing" );
+ f->AddAnonymizeElement( 0x0010, 0x1040,"Sing-sing" );
// Patient's Mother's Birth Name
- f1->AddAnonymizeElement( 0x0010, 0x1060,"Vampirella" );
+ f->AddAnonymizeElement( 0x0010, 0x1060,"Vampirella" );
// 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 remains untouched in memory
- f1->AnonymizeNoLoad();
+ f->AnonymizeNoLoad();
// No need to write the File : modif were done on disc !
// File was overwritten ...
// ============================================================
// Remove the Anonymize list
// ============================================================
- f1->ClearAnonymizeList();
+ f->ClearAnonymizeList();
- delete f1;
+ delete f;
return 0;
}
Program: gdcm
Module: $RCSfile: MakeDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/07/05 13:26:32 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/07/07 17:31:53 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
dcmdir->SetEndMethod(EndMethod);
dcmdir->SetLoadMode(loadMode);
- dcmdir->Load(dirName);
+ dcmdir->SetFileName(dirName);
+
+ dcmdir->Load();
// ----- Check the result
Program: gdcm
Module: $RCSfile: PrintDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/06/08 08:09:07 $
- Version: $Revision: 1.23 $
+ Date: $Date: 2005/07/07 17:31:53 $
+ Version: $Revision: 1.24 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
return 0;
}
- gdcm::DicomDir *e1;
+ gdcm::DicomDir *f;
gdcm::TSKey v;
gdcm::DicomDirPatient *pa;
// new style is useless, since it has no effect for *reading* a DICOMDIR
// (only meaningfull when *creating* a DICOMDIR)
- e1 = new gdcm::DicomDir( fileName );
+ f = new gdcm::DicomDir( fileName );
- //e1 = new gdcm::DicomDir();
- //e1->SetParseDir(false);
- //e1->Load( fileName );
+ //f = new gdcm::DicomDir();
+ //f->SetParseDir(false);
+ //f->Load( fileName );
// Test if the DicomDir is readable
- if( !e1->IsReadable() )
+ if( !f->IsReadable() )
{
std::cout<<" DicomDir '"<<fileName
<<"' is not readable"<<std::endl
<<" ...Failed"<<std::endl;
- delete e1;
+ delete f;
return 1;
}
- e1->SetPrintLevel(level);
+ f->SetPrintLevel(level);
// Test if the DicomDir contains any Patient
- pa = e1->GetFirstPatient();
+ pa = f->GetFirstPatient();
if ( pa == 0)
{
std::cout<<" DicomDir '"<<fileName
<<" has no patient"<<std::endl
<<" ...Failed"<<std::endl;
- delete e1;
+ delete f;
return 1;
}
<< " = PATIENT List =========================================="
<< std::endl<< std::endl;
- pa = e1->GetFirstPatient();
+ pa = f->GetFirstPatient();
while (pa)
{
std::cout << pa->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
- pa = e1->GetNextPatient();
+ pa = f->GetNextPatient();
}
break;
<< " = PATIENT/STUDY List ======================================="
<< std::endl<< std::endl;
- pa = e1->GetFirstPatient();
+ pa = f->GetFirstPatient();
while ( pa ) // on degouline les PATIENT de ce DICOMDIR
{
std::cout << pa->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
std::cout << "--- "<< st->GetEntryValue(0x0008, 0x1030) << std::endl; // Study Description
st = pa->GetNextStudy();
}
- pa = e1->GetNextPatient();
+ pa = f->GetNextPatient();
}
break;
<< " = PATIENT/STUDY/SERIE List =================================="
<< std::endl<< std::endl;
- pa = e1->GetFirstPatient();
+ pa = f->GetFirstPatient();
while ( pa ) // on degouline les PATIENT de ce DICOMDIR
{
// Patient's Name, Patient ID
}
st = pa->GetNextStudy();
}
- pa = e1->GetNextPatient();
+ pa = f->GetNextPatient();
}
break;
<< " = PATIENT/STUDY/SERIE/IMAGE List ============================"
<< std::endl<< std::endl;
- pa = e1->GetFirstPatient();
+ pa = f->GetFirstPatient();
while ( pa ) { // les PATIENT de ce DICOMDIR
// Patient's Name, Patient ID
std::cout << "Pat.Name:[" << pa->GetEntryValue(0x0010, 0x0010) <<"]"; // Patient's Name
}
st = pa->GetNextStudy();
}
- pa = e1->GetNextPatient();
+ pa = f->GetNextPatient();
}
break;
std::cout << std::endl << std::endl
<< " = DICOMDIR full content =========================================="
<< std::endl<< std::endl;
- e1->Print();
+ f->Print();
break;
} // end switch
<< " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
<< std::endl<< std::endl;
- itPatient = e1->GetDicomDirPatients().begin();
- while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline les PATIENT de ce DICOMDIR
+ itPatient = f->GetDicomDirPatients().begin();
+ while ( itPatient != f->GetDicomDirPatients().end() ) { // on degouline les PATIENT de ce DICOMDIR
std::cout << (*itPatient)->GetEntryValue(0x0010, 0x0010) << std::endl; // Patient's Name
itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
*/
- if(e1->IsReadable())
+ if(f->IsReadable())
std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
else
std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
std::cout<<std::flush;
- delete e1;
+ delete f;
return(0);
}
Program: gdcm
Module: $RCSfile: PrintFile.cxx,v $
Language: C++
- Date: $Date: 2005/07/05 13:26:32 $
- Version: $Revision: 1.44 $
+ Date: $Date: 2005/07/07 17:31:53 $
+ Version: $Revision: 1.45 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/* if unused Param we give up */
if ( am->ArgMgrPrintUnusedLabels() )
- {
+ {
am->ArgMgrUsage(usage);
delete am;
return 0;
gdcm::File *f = new gdcm::File();
f->SetLoadMode(loadMode);
+ f->SetFileName( fileName );
+ bool res = f->Load(); // just to see
- bool res = f->Load( fileName );
if ( !res )
{
delete f;
Program: gdcm
Module: $RCSfile: ReWrite.cxx,v $
Language: C++
- Date: $Date: 2005/06/17 12:37:20 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2005/07/07 17:31:53 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// ----------- End Arguments Manager ---------
- gdcm::File *e1 = new gdcm::File();
- e1->SetLoadMode(loadMode);
-
- bool res = e1->Load( fileName );
+ gdcm::File *f = new gdcm::File();
+ f->SetLoadMode( loadMode );
+ f->SetFileName( fileName );
+ bool res = f->Load();
if ( !res )
{
- delete e1;
+ delete f;
return 0;
}
- if (!e1->IsReadable())
+ if (!f->IsReadable())
{
std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
- delete e1;
+ delete f;
return 0;
}
- gdcm::FileHelper *f1 = new gdcm::FileHelper(e1);
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
void *imageData;
int dataSize;
if (rgb)
{
- dataSize = f1->GetImageDataSize();
- imageData = f1->GetImageData(); // somewhat important... can't remember
- f1->SetWriteModeToRGB();
+ dataSize = fh->GetImageDataSize();
+ imageData = fh->GetImageData(); // somewhat important... can't remember
+ fh->SetWriteModeToRGB();
}
else
{
- dataSize = f1->GetImageDataRawSize();
- imageData = f1->GetImageDataRaw();// somewhat important... can't remember
- f1->SetWriteModeToRaw();
+ dataSize = fh->GetImageDataRawSize();
+ imageData = fh->GetImageDataRaw();// somewhat important... can't remember
+ fh->SetWriteModeToRaw();
}
if ( imageData == 0 ) // to avoid warning
std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
int nX,nY,nZ,sPP,planarConfig;
std::string pixelType, transferSyntaxName;
- nX=e1->GetXSize();
- nY=e1->GetYSize();
- nZ=e1->GetZSize();
+ nX=f->GetXSize();
+ nY=f->GetYSize();
+ nZ=f->GetZSize();
std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
- pixelType = e1->GetPixelType();
- sPP = e1->GetSamplesPerPixel();
- planarConfig = e1->GetPlanarConfiguration();
+ pixelType = f->GetPixelType();
+ sPP = f->GetSamplesPerPixel();
+ planarConfig = f->GetPlanarConfiguration();
std::cout << " pixelType=" << pixelType
<< " SampleserPixel=" << sPP
<< " PlanarConfiguration=" << planarConfig
<< " PhotometricInterpretation="
- << e1->GetEntryValue(0x0028,0x0004)
+ << f->GetEntryValue(0x0028,0x0004)
<< std::endl;
- int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
+ int numberOfScalarComponents=f->GetNumberOfScalarComponents();
std::cout << "NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
- transferSyntaxName = e1->GetTransferSyntaxName();
+ transferSyntaxName = f->GetTransferSyntaxName();
std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
switch (mode[0])
// from a full gdcm readable File
std::cout << "WriteACR" << std::endl;
- f1->WriteAcr(outputFileName);
+ fh->WriteAcr(outputFileName);
break;
case 'D' : // Not documented in the 'usage', because the method is known to be bugged.
// from a full gdcm readable File
std::cout << "WriteDCM Implicit VR" << std::endl;
- f1->WriteDcmImplVR(outputFileName);
+ fh->WriteDcmImplVR(outputFileName);
break;
case 'X' :
// from a full gdcm readable File
std::cout << "WriteDCM Explicit VR" << std::endl;
- f1->WriteDcmExplVR(outputFileName);
+ fh->WriteDcmExplVR(outputFileName);
break;
case 'R' :
// Writting a Raw File,
std::cout << "WriteRaw" << std::endl;
- f1->WriteRawData(outputFileName);
+ fh->WriteRawData(outputFileName);
break;
}
- delete e1;
- delete f1;
+ delete f;
+ delete fh;
return 0;
}
Program: gdcm
Module: $RCSfile: TestWrite.cxx,v $
Language: C++
- Date: $Date: 2005/06/15 09:54:13 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2005/07/07 17:31:53 $
+ Version: $Revision: 1.21 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
std::string fileNameToWrite;
- gdcm::File *e1;
- gdcm::FileHelper *f1;
+ gdcm::File *f;
+ gdcm::FileHelper *fh;
void *imageData;
int dataSize;
/*
if (0) { // Just to keep the code for further use
std::cout <<std::endl << "-------- Test gdcmFile ------" <<std::endl;
- e1 = new gdcmFileHelper(argv[1]);
- if (!f1->GetFile()->IsReadable()) {
+ f = new gdcmFileHelper(argv[1]);
+ if (!fh->GetFile()->IsReadable()) {
std::cout << "Sorry, not a DICOM / ACR File" <<std::endl;
exit(0);
}
std::cout << std::endl << "----------------------> after new gdcmFile"
<< std::endl;
- e1->PrintEntry();
+ f->PrintEntry();
std::cout <<std::endl <<"---------------------------------------"
<<std::endl;
}
std::string fileName = argv[1];
std::string mode = argv[2];
- //e1 = new gdcm::File( fileName.c_str() );
+ //f = new gdcm::File( fileName.c_str() );
// new style :
- e1 = new gdcm::File( );
- e1->SetLoadMode(0);
- e1->Load( fileName.c_str() );
-
- if (!e1->IsReadable())
+ f = new gdcm::File( );
+ f->SetLoadMode(0);
+ f->SetFileName( fileName );
+ bool res = f->Load();
+ if ( !res )
{
std::cerr << "Sorry, not a Readable DICOM / ACR File" <<std::endl;
return 0;
}
- // e1->Print();
+ // f->Print();
- f1 = new gdcm::FileHelper(e1);
- dataSize = f1->GetImageDataSize();
- imageData= f1->GetImageData();
+ fh = new gdcm::FileHelper(f);
+ dataSize = fh->GetImageDataSize();
+ imageData= fh->GetImageData();
// ---
std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
int nX,nY,nZ,sPP,planarConfig;
std::string pixelType, transferSyntaxName;
- nX=e1->GetXSize();
- nY=e1->GetYSize();
- nZ=e1->GetZSize();
+ nX=f->GetXSize();
+ nY=f->GetYSize();
+ nZ=f->GetZSize();
std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
- pixelType = e1->GetPixelType();
- sPP = e1->GetSamplesPerPixel();
- planarConfig = e1->GetPlanarConfiguration();
+ pixelType = f->GetPixelType();
+ sPP = f->GetSamplesPerPixel();
+ planarConfig = f->GetPlanarConfiguration();
std::cout << " pixelType=" << pixelType
<< " SampleserPixel=" << sPP
<< " PlanarConfiguration=" << planarConfig
<< " PhotometricInterpretation="
- << e1->GetEntryValue(0x0028,0x0004)
+ << f->GetEntryValue(0x0028,0x0004)
<< std::endl;
- int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
+ int numberOfScalarComponents=f->GetNumberOfScalarComponents();
std::cout << "NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
- transferSyntaxName = e1->GetTransferSyntaxName();
+ transferSyntaxName = f->GetTransferSyntaxName();
std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
/*
&& transferSyntaxName != "Uncompressed ACR-NEMA" ) {
std::cout << std::endl << "==========================================="
<< std::endl;
- f1->GetPixelReadConverter()->Print();
+ fh->GetPixelReadConverter()->Print();
std::cout << std::endl << "==========================================="
<< std::endl;
}
fileNameToWrite = fileName + ".ACR";
std::cout << "WriteACR" << std::endl;
- f1->WriteAcr(fileNameToWrite);
+ fh->WriteAcr(fileNameToWrite);
break;
case 'd' : // Not document in the 'usage', because the method is knowed to be bugged.
fileNameToWrite = fileName + ".DCM";
std::cout << "WriteDCM Implicit VR" << std::endl;
- f1->WriteDcmImplVR(fileNameToWrite);
+ fh->WriteDcmImplVR(fileNameToWrite);
break;
case 'x' :
fileNameToWrite = fileName + ".XDCM";
std::cout << "WriteDCM Explicit VR" << std::endl;
- f1->WriteDcmExplVR(fileNameToWrite);
+ fh->WriteDcmExplVR(fileNameToWrite);
break;
case 'r' :
fileNameToWrite = fileName + ".RAW";
std::cout << "WriteRaw" << std::endl;
- f1->WriteRawData(fileNameToWrite);
+ fh->WriteRawData(fileNameToWrite);
break;
case 'v' :
- if ( f1->GetFile()->GetBitsAllocated() == 8)
+ if ( fh->GetFile()->GetBitsAllocated() == 8)
{
std::cout << "videoinv for 8 bits" << std::endl;
for (int i=0; i<dataSize; i++)
}
fileNameToWrite = fileName + ".VDCM";
std::cout << "WriteDCM Explicit VR + VideoInv" << std::endl;
- f1->WriteDcmExplVR(fileNameToWrite);
+ fh->WriteDcmExplVR(fileNameToWrite);
break;
}
- delete e1;
- delete f1;
+ delete f;
+ delete fh;
return 0;
}
Program: gdcm
Module: $RCSfile: exAnonymize.cxx,v $
Language: C++
- Date: $Date: 2005/03/02 17:19:45 $
- Version: $Revision: 1.3 $
+ 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
#include <iostream>
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 << 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"
<<std::endl;
// ============================================================
// We need a gdcm::FileHelper, since we want to load the pixels
- gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
// (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one)
- uint8_t *imageData = fh1->GetImageData();
+ uint8_t *imageData = fh->GetImageData();
if ( imageData == 0 )
{
// 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;
}
Program: gdcm
Module: $RCSfile: exAnonymizeNoLoad.cxx,v $
Language: C++
- Date: $Date: 2005/05/04 07:29:17 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ Version: $Revision: 1.9 $
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::File *f;
gdcm::Debug::DebugOn();
// ============================================================
// Read the input image.
// ============================================================
- bool res;
- f1 = new gdcm::File( );
- f1->SetLoadMode(NO_SEQ - NO_SHADOW);
- res = f1->Load(fileName);
+ f = new gdcm::File( );
+ f->SetLoadMode(NO_SEQ - NO_SHADOW);
+ f->SetFileName( fileName );
+ bool res = f->Load();
// gdcm::File::IsReadable() is no usable here, because we deal with
// any kind of gdcm::Readable *document*
// 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" );
// Patient's Birthdate
- f1->AddAnonymizeElement( 0x0010, 0x0030,"11.11.1111" );
+ f->AddAnonymizeElement( 0x0010, 0x0030,"11.11.1111" );
// Patient's Adress
- f1->AddAnonymizeElement( 0x0010, 0x1040,"Sing-sing" );
+ f->AddAnonymizeElement( 0x0010, 0x1040,"Sing-sing" );
// Patient's Mother's Birth Name
- f1->AddAnonymizeElement( 0x0010, 0x1060,"Vampirella" );
+ f->AddAnonymizeElement( 0x0010, 0x1060,"Vampirella" );
// 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 remains untouched in memory
- f1->AnonymizeNoLoad();
+ f->AnonymizeNoLoad();
// No need to write the File : modif were done on disc !
// File was overwritten ...
// ============================================================
// Remove the Anonymize list
// ============================================================
- f1->ClearAnonymizeList();
+ f->ClearAnonymizeList();
- delete f1;
+ delete f;
return 0;
}
Program: gdcm
Module: $RCSfile: exBuildUpDicomDir.cxx,v $
Language: C++
- Date: $Date: 2005/02/03 15:44:50 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
gdcm::DicomDir *dcmdir;
dcmdir = new gdcm::DicomDir();
- std::cout << "\n------- BuildUpDicomDir: Test Print Meta only -----" << std::endl;
+ std::cout << "\n------- BuildUpDicomDir: Test Print Meta only -----"
+ << std::endl;
((gdcm::Document *)dcmdir)->Print();
gdcm::DicomDirPatient *p1=dcmdir->NewPatient();
Program: gdcm
Module: $RCSfile: exColorToRGB.cxx,v $
Language: C++
- Date: $Date: 2005/07/06 15:49:31 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ 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
// ============================================================
// a gdcm::File contains all the Dicom Field but the Pixels Element
- gdcm::File *f1= new gdcm::File( fileName );
-
-
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"
<<std::endl;
std::cout << " ... is readable " << std::endl;
/*
- if (!f1->IsMonochrome()) {
+ if (!f->IsMonochrome()) {
std::cerr << "Sorry, " << fileName <<" not a 'color' File "
<< " "
<<std::endl;
// ============================================================
// We need a gdcm::FileHelper, since we want to load the pixels
- gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
// (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one)
- uint8_t *imageData = fh1->GetImageData();
+ uint8_t *imageData = fh->GetImageData();
if ( imageData == 0 )
{
}
-
-
// ------ User wants write a new image without shadow groups -------------
// ------ without Sequences -------------
gdcm::FileHelper *copy = new gdcm::FileHelper( output );
- gdcm::DocEntry *d = f1->GetFirstEntry();
+ gdcm::DocEntry *d = f->GetFirstEntry();
while(d)
{
// We skip SeqEntries, since user cannot do much with them
// We skip gdcm::SeqEntries
}
}
- d = f1->GetNextEntry();
+ d = f->GetNextEntry();
}
// User knows the image is a 'color' one -RGB, YBR, Palette Color-
// and wants to write it as RGB
- copy->SetImageData(imageData, fh1->GetImageDataSize());
+ copy->SetImageData(imageData, fh->GetImageDataSize());
copy->SetWriteModeToRGB();
copy->WriteDcmExplVR( output );
- delete f1;
- delete fh1;
+ delete f;
+ delete fh;
delete copy;
exit (0);
Program: gdcm
Module: $RCSfile: exGC.cxx,v $
Language: C++
- Date: $Date: 2005/07/06 15:49:31 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// ============================================================
// a gdcm::File contains all the Dicom Field but the Pixels Element
- gdcm::File *f1= new gdcm::File( fileName );
-
-
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"
<<std::endl;
std::cout << " ... is readable " << std::endl;
/*
- if (!f1->IsMonochrome()) {
+ if (!f->IsMonochrome()) {
std::cerr << "Sorry, " << fileName <<" not a 'color' File "
<< " "
<<std::endl;
// ============================================================
// We need a gdcm::FileHelper, since we want to load the pixels
- gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
// (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one)
- uint8_t *imageData = fh1->GetImageData();
+ uint8_t *imageData = fh->GetImageData();
if ( imageData == 0 )
{
gdcm::FileHelper *copy = new gdcm::FileHelper( output );
- gdcm::DocEntry *d = f1->GetFirstEntry();
+ gdcm::DocEntry *d = f->GetFirstEntry();
while(d)
{
// We skip SeqEntries, since user cannot do much with them
// We skip gdcm::SeqEntries
}
}
- d = f1->GetNextEntry();
+ d = f->GetNextEntry();
}
- int imageSize = fh1->GetImageDataSize();
+ int imageSize = fh->GetImageDataSize();
// Black up all 'grey' pixels
int i;
int n = 0;
copy->WriteDcmExplVR( output );
- delete f1;
- delete fh1;
+ delete f;
+ delete fh;
delete copy;
exit (0);
Program: gdcm
Module: $RCSfile: exGrey2RGB.cxx,v $
Language: C++
- Date: $Date: 2005/06/15 10:06:36 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
return 1;
}
}
-
+
gdcm::FileHelper *fh = new gdcm::FileHelper( filename );
size_t dataSize = fh->GetImageDataSize();
Program: gdcm
Module: $RCSfile: exImageLighten.cxx,v $
Language: C++
- Date: $Date: 2005/07/06 15:49:31 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ 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
#include <stdlib.h> // for exit
int main(int argc, char *argv[])
-{
- gdcm::File *f1;
-
+{
std::cout << "-----------------------------------------------" << std::endl;
std::cout << "Removes from a full gdcm-readable Dicom image" << std::endl;
std::cout << " all the 'Shadow groups' and the 'Sequence' entries"
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"
<<std::endl;
// to load the Palettes Color (if any)
// First, create a gdcm::FileHelper
- gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
+ gdcm::FileHelper *fh = new gdcm::FileHelper(f);
// Load the pixels, DO NOT transform LUT (if any) into RGB Pixels
- uint8_t *imageDataRaw = fh1->GetImageDataRaw();
+ uint8_t *imageDataRaw = fh->GetImageDataRaw();
// Get the image data size
- size_t dataRawSize = fh1->GetImageDataRawSize();
+ size_t dataRawSize = fh->GetImageDataRawSize();
// ============================================================
// Create a new gdcm::Filehelper, to hold new image.
// Selective copy of the entries (including Pixel Element).
// ============================================================
- gdcm::DocEntry *d = f1->GetFirstEntry();
+ gdcm::DocEntry *d = f->GetFirstEntry();
- d = f1->GetFirstEntry();
+ d = f->GetFirstEntry();
while(d)
{
// We skip SeqEntries, since user cannot do much with them
// We skip gdcm::SeqEntries
}
}
- d = f1->GetNextEntry();
+ d = f->GetNextEntry();
}
// User wants to keep the Palette Color -if any-
std::cout << std::endl
<< "------------------------------------------------------------"
<< std::endl;
- delete f1;
- delete fh1;
+ delete f;
+ delete fh;
delete copy;
exit (0);
Program: gdcm
Module: $RCSfile: exOverlaysACR.cxx,v $
Language: C++
- Date: $Date: 2005/05/19 15:47:20 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ 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::File *f;
//gdcm::Debug::DebugOn();
//std::cout << argv[1] << std::endl;
- f1 = new gdcm::File( );
+ f = new gdcm::File( );
- f1->SetLoadMode(NO_SEQ | NO_SHADOW);
- f1->Load( fileName );
+ f->SetLoadMode(NO_SEQ | NO_SHADOW);
+ f->SetFileName( fileName );
+ bool res = f->Load();
if( gdcm::Debug::GetDebugFlag() )
{
std::cout << "---------------------------------------------" << std::endl;
- f1->Print();
+ f->Print();
std::cout << "---------------------------------------------" << std::endl;
}
- if (!f1->IsReadable()) {
+ if (!res) {
std::cout << "Sorry, " << fileName <<" not a gdcm-readable "
<< "DICOM / ACR File"
<<std::endl;
- delete f1;
+ delete f;
return 0;
}
std::cout << " ... is readable " << std::endl;
// Check whether image contains Overlays ACR-NEMA style.
// ============================================================
- int bitsAllocated = f1->GetBitsAllocated();
+ int bitsAllocated = f->GetBitsAllocated();
if ( bitsAllocated <= 8 )
{
std::cout << " 8 bits pixel image cannot contain Overlays " << std::endl;
- delete f1;
+ delete f;
return 0;
}
- std::string s1 = f1->GetEntryValue(0x6000, 0x0102);
+ std::string s1 = f->GetEntryValue(0x6000, 0x0102);
if (s1 == gdcm::GDCM_UNFOUND)
{
std::cout << " Image doesn't contain any Overlay " << std::endl;
- delete f1;
+ delete f;
return 0;
}
std::cout << " File is read! " << std::endl;
// We don't use a gdcm::FileHelper, since it rubs out
// the 'non image' bits of the pixels...
- int nx = f1->GetXSize();
- int ny = f1->GetYSize();
+ int nx = f->GetXSize();
+ int ny = f->GetYSize();
std::cout << "Dimensions " << ny << " " <<ny << std::endl;
- gdcm::DocEntry *p = f1->GetDocEntry(f1->GetGrPixel(), f1->GetNumPixel());
+ gdcm::DocEntry *p = f->GetDocEntry(f->GetGrPixel(), f->GetNumPixel());
if (p == 0)
std::cout << "Pixels element not found" << std::endl;
else
if (fp == 0)
{
std::cout << "Unable to open File" << std::endl;
- delete f1;
+ delete f;
return 0;
}
else
<< "readable. expected length :" << nx*ny
<< " " << "read length : " << lgt
<< std::endl;
- delete f1;
+ delete f;
delete pixels;
return 0;
}
gdcm::FileHelper *fh = 0;
-while ( (strOvlBitPosition = f1->GetEntryValue(currentOvlGroup, 0x0102))
+while ( (strOvlBitPosition = f->GetEntryValue(currentOvlGroup, 0x0102))
!= gdcm::GDCM_UNFOUND )
{
- strOverlayLocation = f1->GetEntryValue(currentOvlGroup, 0x0200);
+ strOverlayLocation = f->GetEntryValue(currentOvlGroup, 0x0200);
if ( strOverlayLocation != gdcm::GDCM_UNFOUND )
{
overlayLocation = atoi(strOverlayLocation.c_str());
- if ( overlayLocation != f1->GetGrPixel() )
+ if ( overlayLocation != f->GetGrPixel() )
{
std::cout << "Big Trouble : Overlays are NOT in the Pixels Group "
<< std::hex << "(" << overlayLocation << " vs "
- << f1->GetGrPixel() << std::endl;
+ << f->GetGrPixel() << std::endl;
// Actually, here, we should (try to) read the overlay location
// and go on the job.
continue;
i++;
}
- delete f1;
- if (f1)
+ delete f;
+ if (f)
delete fh;
if (fileToBuild)
delete fileToBuild;
Program: gdcm
Module: $RCSfile: exReadPapyrus.cxx,v $
Language: C++
- Date: $Date: 2005/06/27 15:46:27 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2005/07/07 17:31:54 $
+ 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
}
int loadMode = 0x0; // load everything
- gdcm::File *e1 = new gdcm::File();
- e1->SetLoadMode(loadMode);
+ gdcm::File *f = new gdcm::File();
+ f->SetLoadMode( loadMode );
+ f->SetFileName( fileName );
+ bool res = f->Load();
- bool res = e1->Load( fileName );
if ( !res )
{
- delete e1;
+ delete f;
return 0;
}
// Look for private Papyrus Sequence
- gdcm::SeqEntry *seqPapyrus= e1->GetSeqEntry(0x0041, 0x1050);
+ gdcm::SeqEntry *seqPapyrus= f->GetSeqEntry(0x0041, 0x1050);
if (!seqPapyrus)
{
std::cout << "NOT a Papyrus File : " << fileName <<std::endl;
- delete e1;
+ delete f;
return 1;
}
// gdcm::FileHelper *original = new gdcm::FileHelper( fileName );
// gdcm::File *h = original->GetFile();
- //gdcm::FileHelper *f1 = new gdcm::FileHelper(e1);
+ //gdcm::FileHelper *f1 = new gdcm::FileHelper(f);
gdcm::SQItem *sqi = seqPapyrus->GetFirstSQItem();
if (sqi == 0)
{
std::cout << "NO SQItem found within private Papyrus Sequence"
<< std::endl;
- delete e1;
+ delete f;
return 1;
}
// Modality, Transfer Syntax, Study Date, Study Time
// Patient Name, Media Storage SOP Instance UID, etc
- MediaStSOPinstUID = e1->GetEntryValue(0x0002,0x0002);
- TransferSyntax = e1->GetEntryValue(0x0002,0x0010);
+ MediaStSOPinstUID = f->GetEntryValue(0x0002,0x0002);
+ TransferSyntax = f->GetEntryValue(0x0002,0x0010);
StudyDate = sqi->GetEntryValue(0x0008,0x0020);
StudyTime = sqi->GetEntryValue(0x0008,0x0030);
Modality = sqi->GetEntryValue(0x0008,0x0060);