}
//--------------------------------------------------------------------
-//--------------------------------------------------------------------
-// Read a dicom header
-gdcm::File * clitk::readDicomHeader(const std::string & filename,
- const bool verbose)
-{
-#if GDCM_MAJOR_VERSION == 2
- gdcm::Reader hreader;
- hreader.SetFileName(filename.c_str());
- hreader.Read();
- gdcm::SmartPointer<gdcm::File> p = hreader.GetFile();
- return p;
-#else
- if (verbose) {
- std::cout << "Reading DICOM <" << filename << ">" << std::endl;
- }
- gdcm::File *header = new gdcm::File();
- header->SetFileName(filename);
- header->SetMaxSizeLoadEntry(16384); // required ?
- header->Load();
- return header;
-#endif
-}
-///--------------------------------------------------------------------
-
//--------------------------------------------------------------------
itk::ImageIOBase::Pointer clitk::readImageHeader(const std::string & filename, bool exit_on_error)
{
#include "itkImageFileReader.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
-#include "gdcmFile.h"
-#if GDCM_MAJOR_VERSION == 2
- #include "gdcmReader.h"
-#else
- #include "gdcmFileHelper.h"
-#endif
namespace clitk {
// Determine pixetype, dimension and number of pixel components of an image file
void ReadImageDimensionAndPixelType(const std::string & filename, int & dimension, std::string & pixeType, int & components);
- //--------------------------------------------------------------------
- // Read a dicom header
- gdcm::File * readDicomHeader(const std::string & filename, const bool verbose=false);
-
//--------------------------------------------------------------------
template<class ImageType>
int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image,
#include "clitkImageCommon.h"
#include "vvImageReader.h"
#include "vvImageWriter.h"
+#include <gdcmFile.h>
+#if GDCM_MAJOR_VERSION == 2
+ #include <gdcmImageHelper.h>
+ #include <gdcmAttribute.h>
+ #include <gdcmReader.h>
+#endif
//====================================================================
int main(int argc, char * argv[])
std::vector<double> sliceLocations;
for(unsigned int i=0; i<args_info.inputs_num; i++) {
//std::cout << "Reading <" << input_files[i] << std::endl;
- gdcm::File * header = clitk::readDicomHeader(input_files[i]);
- sliceLocations.push_back(header->GetZOrigin());
- if (header->GetPixelSize() != 2) {
+#if GDCM_MAJOR_VERSION == 2
+ gdcm::Reader hreader;
+ hreader.SetFileName(input_files[i].c_str());
+ hreader.Read();
+ std::vector<double> theorigin = gdcm::ImageHelper::GetOriginValue(hreader.GetFile());
+ sliceLocations.push_back(theorigin[2]);
+ gdcm::Attribute<0x28, 0x100> pixel_size;
+ gdcm::DataSet& ds = hreader.GetFile().GetDataSet();
+ pixel_size.SetFromDataSet(ds);
+ if (pixel_size.GetValue() != 16)
+ {
std::cerr << "Pixel type 2 bytes ! " << std::endl;
std::cerr << "In file " << input_files[i] << std::endl;
exit(0);
}
+#else
+ gdcm::File *header = new gdcm::File();
+ header->SetFileName(input_files[i]);
+ header->SetMaxSizeLoadEntry(16384); // required ?
+ header->Load();
+ sliceLocations.push_back(header->GetZOrigin());
+ if (header->GetPixelSize() != 2) {
+ std::cerr << "Pixel type 2 bytes ! " << std::endl;
+ std::cerr << "In file " << input_files[i] << std::endl;
+ exit(0);
+ }
+#endif
}
//===========================================
// itk (gdcm) include
#include "gdcmFile.h"
+#if GDCM_MAJOR_VERSION == 2
+ #include "gdcmReader.h"
+ #include "gdcmPrinter.h"
+#endif
//--------------------------------------------------------------------
int main(int argc, char * argv[])
// Loop files
for(unsigned int i=0; i<args_info.inputs_num; i++) {
+#if GDCM_MAJOR_VERSION == 2
+ gdcm::Reader reader;
+ reader.SetFileName(args_info.inputs[i]);
+ reader.Read();
+ gdcm::Printer printer;
+ printer.SetFile(reader.GetFile());
+ printer.SetStyle(gdcm::Printer::VERBOSE_STYLE);
+ printer.Print( std::cout );
+#else
gdcm::File *header = new gdcm::File();
header->SetFileName(args_info.inputs[i]);
header->SetMaxSizeLoadEntry(163840);
header->Load();
header->Print();
+#endif
}
// this is the end my friend