[Insight-users] Reading Analyze 7.5 images with ITK
A.Burak Yoldemir
yoldemir at gmail.com
Mon Nov 9 13:21:10 EST 2009
I added the try/catch block. It gives a segmentation fault, however does not
throw an exception. Here is the code and the output:
*Code:*
typedef unsigned char PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
typedef itk::NumericSeriesFileNames NameGeneratorType;
NameGeneratorType::Pointer nameGenerator =
NameGeneratorType::New();
nameGenerator->SetSeriesFormat(
"/root/Desktop/default_10-v1.0.3/default_10-v1.0.3/phantom_01/clean/dwi-%02d.hdr"
);
nameGenerator->SetStartIndex( 0 );
nameGenerator->SetEndIndex( 66 );
nameGenerator->SetIncrementIndex( 1 );
reader->SetImageIO( itk::AnalyzeImageIO::New() );
reader->SetFileNames( nameGenerator->GetFileNames() );
cout << "Before try/catch" << endl;
try
{
cout << "Try1" << endl;
reader->Update();
cout << "Try2" << endl;
}
catch (itk::ExceptionObject &e)
{
std::cerr << e << std::endl;
return EXIT_FAILURE;
}
*Output:*
Before try/catch
Try1
Segmentation fault
Ahmet Burak Yoldemir
On Sun, Nov 8, 2009 at 11:23 PM, Bill Lorensen <bill.lorensen at gmail.com>wrote:
> Place a try/catch block around the reader->Update() and print the
> exception if one is thrown.
>
> try
> {
> reader->Update();
> }
> catch (itk::ExceptionObject &e)
> {
> std::cerr << e << std::endl;
> return EXIT_FAILURE;
> }
>
>
> On Sun, Nov 8, 2009 at 3:40 PM, A.Burak Yoldemir <yoldemir at gmail.com>
> wrote:
> > Hello,
> >
> > I am trying to read Analyze 7.5 images using ITK, however I am getting
> > segfault. Here is the relevant code:
> >
> > typedef unsigned char PixelType;
> > const unsigned int Dimension = 3;
> > typedef itk::Image< PixelType, Dimension > ImageType;
> >
> > typedef itk::ImageSeriesReader< ImageType > ReaderType;
> >
> > ReaderType::Pointer reader = ReaderType::New();
> >
> > typedef itk::NumericSeriesFileNames NameGeneratorType;
> > NameGeneratorType::Pointer nameGenerator =
> > NameGeneratorType::New();
> >
> > nameGenerator->SetSeriesFormat(
> >
> "/root/Desktop/default_10-v1.0.3/default_10-v1.0.3/phantom_01/clean/dwi-%02d.hdr"
> > );
> >
> > nameGenerator->SetStartIndex( 0 );
> > nameGenerator->SetEndIndex( 66 );
> > nameGenerator->SetIncrementIndex( 1 );
> >
> > reader->SetImageIO( itk::AnalyzeImageIO::New() );
> >
> > reader->SetFileNames( nameGenerator->GetFileNames() );
> > reader->Update();
> >
> > I am getting a segmentation fault when the update method is called. Any
> > ideas?
> >
> > Thanks in advance,
> >
> >
> > Ahmet Burak Yoldemi
> > _____________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://www.kitware.com/products/protraining.html
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.itk.org/mailman/listinfo/insight-users
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091109/6309e059/attachment-0001.htm>
More information about the Insight-users
mailing list