[Insight-users] Reading a series of images and then segmenting one image at a time

Ken Urish ken.urish at gmail.com
Mon Feb 28 02:00:27 EST 2005


Im reading a series of images but I want to process one image at a time.
I am using the DicomSeriesReadImageWrite.cxx as an example.  I create
the vector called fileNames that contains the file names generated by
nameGenerator. Then I try to read each individual image in a lop by
using "reader->SetFileName( fileNames.at(p) );" .  The program crashes
when I update the reader.  I enclosed a piece of the code below.  Your
help is greatly appreciated.  If there's a better way to do this
please just point me in teh right direction.

Thanks
--Ken--

  typedef itk::NumericSeriesFileNames    NameGeneratorType;
  NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
  nameGenerator->SetStartIndex( 0 );
  nameGenerator->SetEndIndex( 10 );
  nameGenerator->SetIncrementIndex( 1 );

  nameGenerator->SetSeriesFormat( "file%03d.tif" );
  typedef std::vector<std::string> fileNamesContainer;
  fileNamesContainer fileNames;
  fileNames = nameGenerator->GetFileNames();

for ( int p=0; p<fileNames.size(); p++)
  {
  std::string strd = fileNames.at(p);
  std::cout<<strd.c_str()<<std::endl;
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( strd.c_str() );
  ImagePointer inputImage = reader->GetOutput();
  reader->Update();
***IT CRASHES***


More information about the Insight-users mailing list