Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
-bool FileExists(const char* filename);
+#ifndef _WIN32
+#include <unistd.h> //for access, unlink
+#else
+#include <io.h> //for _access on Win32
+#endif
+
+bool FileExists(const char *filename)
+{
+#ifdef _MSC_VER
+# define access _access
+#endif
+#ifndef R_OK
+# define R_OK 04
+#endif
+ if ( access(filename, R_OK) != 0 )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
-int CopyRescaleDicom(std::string const & filename,
- std::string const & output )
+int CopyRescaleDicom(std::string const &filename,
+ std::string const &output )
- copyF->InsertBinEntry( b->GetBinArea(),b->GetLength(),
- b->GetGroup(),b->GetElement(),
- b->GetVR() );
+ copyF.InsertBinEntry( b->GetBinArea(),b->GetLength(),
+ b->GetGroup(),b->GetElement(),
+ b->GetVR() );
- copyF->InsertValEntry( v->GetValue(),
- v->GetGroup(),v->GetElement(),
- v->GetVR() );
+ copyF.InsertValEntry( v->GetValue(),
+ v->GetGroup(),v->GetElement(),
+ v->GetVR() );
- gdcm::FileHelper *original = new gdcm::FileHelper( originalF );
- gdcm::FileHelper *copy = new gdcm::FileHelper( copyF );
+ gdcm::FileHelper original = gdcm::FileHelper( &originalF );
+ gdcm::FileHelper copy = gdcm::FileHelper( ©F );
- copyF->InsertValEntry( "8", 0x0028, 0x0100); // BitsAllocated
- copyF->InsertValEntry( "8", 0x0028, 0x0101); // BitsStored
- copyF->InsertValEntry( "7", 0x0028, 0x0102); // HighBit
- copyF->InsertValEntry( "0", 0x0028, 0x0103); //Pixel Representation
-
+ copyF.InsertValEntry( "8", 0x0028, 0x0100); // Bits Allocated
+ copyF.InsertValEntry( "8", 0x0028, 0x0101); // Bits Stored
+ copyF.InsertValEntry( "7", 0x0028, 0x0102); // High Bit
+ copyF.InsertValEntry( "0", 0x0028, 0x0103); // Pixel Representation
+
// We assume the value were from 0 to uint16_t max
rescaleSize = dataSize / 2;
rescaleImage = new uint8_t[dataSize];
// We assume the value were from 0 to uint16_t max
rescaleSize = dataSize / 2;
rescaleImage = new uint8_t[dataSize];
- size_t dataSizeWritten = copy->GetImageDataSize();
- uint8_t* imageDataWritten = copy->GetImageData();
+ size_t dataSizeWritten = copy2.GetImageDataSize();
+ uint8_t *imageDataWritten = copy2.GetImageData();
- if (originalF->GetXSize() != copy->GetFile()->GetXSize() ||
- originalF->GetYSize() != copy->GetFile()->GetYSize() ||
- originalF->GetZSize() != copy->GetFile()->GetZSize())
+ if (originalF.GetXSize() != copy2.GetFile()->GetXSize() ||
+ originalF.GetYSize() != copy2.GetFile()->GetYSize() ||
+ originalF.GetZSize() != copy2.GetFile()->GetZSize())
- << "X: " << originalF->GetXSize() << " # "
- << copy->GetFile()->GetXSize() << " | "
- << "Y: " << originalF->GetYSize() << " # "
- << copy->GetFile()->GetYSize() << " | "
- << "Z: " << originalF->GetZSize() << " # "
- << copy->GetFile()->GetZSize() << std::endl;
- delete original;
- delete copy;
- delete originalF;
+ << "X: " << originalF.GetXSize() << " # "
+ << copy2.GetFile()->GetXSize() << " | "
+ << "Y: " << originalF.GetYSize() << " # "
+ << copy2.GetFile()->GetYSize() << " | "
+ << "Z: " << originalF.GetZSize() << " # "
+ << copy2.GetFile()->GetZSize() << std::endl;
// Here we load a gdcmFile and then try to create from scratch a copy of it,
// copying field by field the dicom image
// Here we load a gdcmFile and then try to create from scratch a copy of it,
// copying field by field the dicom image
+ r2 = times(&tms2);
+
+ std::cout
+ << std::setw(150-strlen(gdcmDataImages[i]))
+ << gdcmDataImages[i] << " user time: "
+ << (long) ((tms2.tms_utime) - (tms1.tms_utime))
+ << " system time: "
+ << (long) ((tms2.tms_stime) - (tms1.tms_stime))
+ << "\t elapsed time: " << r2 - r1
+ << std::endl;
+ r4 = times(&tms4);
+
+ std::cout
+ << std::setw(150-strlen("Gross Total")) << " --> "
+ << "Gross Total" << " user time: "
+ << (long) ((tms4.tms_utime) - (tms3.tms_utime))
+ << " system time: "
+ << (long) ((tms4.tms_stime) - (tms3.tms_stime))
+ << "\t elapsed time: " << (long) (r4 - r3)
+ << std::endl;