[Insight-users] A little help with getting Images Read
Luis Ibanez
luis.ibanez at kitware.com
Mon Oct 23 10:16:48 EDT 2006
Hi Jonathan,
Please don't catch the exceptions with "catch(...)"
by doing this, you lose the information about what caused the
exception.
You should catch it first with:
catch( itk::ExceptionObject & excp )
{
std::cerr << excp << std::endl;
}
It is very likely that the message from excp is trying
to tell you what is wrong with the filename and you are
not seeing this message, because you are just catching
a generic exception.
Regards,
Luis
----------------------
Jonathan Wong wrote:
> Sorry. This is probably a simple fix, but I don't understand why it
> doesn't work. For some reason, with the following code, where fn_image1
> is simply argv[1], at reader->Update(), my program always throws an
> exception.
>
> typedef itk::Image < unsigned char, 3 > ImageVType;
> typedef itk::ImageFileReader < ImageVType > ImageReaderType;
> ImageReaderType::Pointer reader = ImageReaderType::New();
> ImageVType::Pointer image;
> try
> {
> reader->SetFileName( fn_image1 );
> reader->Update();
>
> image = reader->GetOutput();
> }
> catch(...)
> {
> std::cout << "Error while reading in fixed image." << std::endl;
> throw;
> }
>
> Using the VS 7.0 debugger it points to itkimagefilereader.txx
>
> // Test if the file can be open for reading access.
> -> std::ifstream readTester;
> readTester.open( m_FileName.c_str() );
>
> I don't quite understand what the problem is. Compiling other examples,
> the filereader seems to function normally. Also the file I'm trying to
> read is in the debug folder, and therefore is in the same path as the
> compiled executable. Information on how to fix this issue would be
> appreciated.
>
> -Jonathan Wong
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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