[Insight-users] Regarding bad_alloc while loading DICOM

Hauke Heibel heibel at cs.tum.edu
Fri Oct 19 17:08:07 EDT 2007


Skipped content of type multipart/alternative-------------- next part --------------
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"

using namespace itk;
using namespace std;

int main(int argc, char* argv[])
{
  const std::string fileName = argv[1];
  
  typedef signed short PixelType;
  const unsigned int   Dimension = 3;

  typedef itk::Image<PixelType, Dimension> ImageType;
  typedef ImageSeriesReader<ImageType>     ReaderType;
  typedef GDCMImageIO                      ImageIOType;
  
  ReaderType::Pointer reader = ReaderType::New();
  ImageIOType::Pointer dicomIO = ImageIOType::New();

  reader->SetImageIO(dicomIO);
  
  FilenamesContainer fileNames;
  fileNames.push_back(fileName);
  
  reader->SetFileNames(fileNames);
  
  try
  {
    reader->Update();
  } 
  catch (std::bad_alloc& ae)
  {
    std::cout << ae.what() << std::endl;
    return -1;
  }
  
  return 0;
}


More information about the Insight-users mailing list