[Insight-users] Reading a series of images and then segmenting
one image at a time
Luis Ibanez
luis.ibanez at kitware.com
Wed Mar 2 20:37:09 EST 2005
Hi Ken,
It is likely that ITK is throwing an exception when you
call Update() in the reader.
Please add a try/catch block around the Update() call,
and print out the message from the exceptions. That
should help to identify the source of the error.
For examples on how to use try/catch blocks look at the
ITK Software Guide:
http://www.itk.org/ItkSoftwareGuide.pdf
Regards,
Luis
------------------
Ken Urish 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
>
>
More information about the Insight-users
mailing list