[Insight-users] image reader update error

Ashish Singh mrasingh at gmail.com
Thu Jan 11 12:46:01 EST 2007


Hi,

I am a newbie to ITK. I was trying to read a set of dicom images from a
directory and then use reader->update() to process each one of them one
after the other. But the reader->update() gives me an error after reading
the first image. Can anyone please tell me how to fix this problem?

This is what my code looks like. It is not the complete code, but only the
relevant part of it.
---------------
  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
  nameGenerator->SetInputDirectory( "D:\\testimages"  );

  typedef std::vector<std::string> FileNamesContainer;
  FileNamesContainer fileNames = nameGenerator->GetInputFileNames();
    unsigned int numberOfFilenames =  fileNames.size();
  std::cout << numberOfFilenames << std::endl;
  unsigned int fni;

  for(fni = 0; fni<numberOfFilenames; fni++)
    {
    std::cout << "filename # " << fni << " = ";
    std::cout << fileNames[fni] << std::endl;
    }

  for(fni = 0; fni<numberOfFilenames; fni++)
  {
  reader->SetFileName( fname);

  reader->SetImageIO( gdcmImageIO );

  try
    {
        reader->Update();//this is where it gives me an error second time in
the loop.
    }
  catch (itk::ExceptionObject & e)
    {
    std::cerr << "exception in file reader " << std::endl;
    std::cerr << e << std::endl;
    return EXIT_FAILURE;
    }
// code for processing the image //
//code for writing the processed image//
}// for loop complete
--------------------------------------
The filenames are correctly read, the code runs fine the first time through
the for loop, but second time it gives an error at the reader->Update()
line.
Can anyone please tell me why is this happening and how to fix it?

Thanks,
Ashish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20070111/7ffe0573/attachment.html


More information about the Insight-users mailing list