[Insight-users] A little help with getting Images Read

Jonathan Wong jon.the.wong at gmail.com
Wed Oct 18 18:21:47 EDT 2006


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20061018/b9d5e664/attachment.html


More information about the Insight-users mailing list