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

Uday Kurkure udaykurkure at yahoo.com
Thu Mar 3 11:19:38 EST 2005


Hello Ken,

Best is add try-catch to your code as Luis suggested.
The possible causes I can think of
- The filenames are not generated correctly.
- The path to the files is not correct.
- If reading only single image, better to use
ImageReader rather than ImageSeriesReader
(DicomSeriesReadImageWrite.cxx)

-Uday


--- Ken Urish <ken.urish at gmail.com> wrote:
> 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***
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


	
		
__________________________________ 
Celebrate Yahoo!'s 10th Birthday! 
Yahoo! Netrospective: 100 Moments of the Web 
http://birthday.yahoo.com/netrospective/


More information about the Insight-users mailing list