[Insight-developers] ImageFileReader and IO factory

Joshua Cates cates at sci . utah . edu
Wed, 6 Aug 2003 15:35:53 -0600 (MDT)


Hi all,

I have noticed that ImageFileReader will only create an ImageIO object 
once.  This means that if your pipeline reads a "foo.mha" image and then 
later you want to reuse the filter to read a "foo.png" image, it fails 
and throws an exception.

The following modification to ImageFileReader<TOutputImage, ConvertPixelTraits>
::GenerateOutputInformation(void) fixes the problem:

change

  if ( m_ImageIO.IsNull() ) //try creating via factory
    {	
    m_UserSpecifiedImageIO = false;
    m_ImageIO = ImageIOFactory::CreateImageIO( m_FileName.c_str(), 
      ImageIOFactory::ReadMode );
    }

to

 if ( m_UserSpecifiedImageIO == false ) //try creating via factory
    {
    m_ImageIO = ImageIOFactory::CreateImageIO( m_FileName.c_str(), 
ImageIOFactory::ReadMode );
    }
  

Anyone see any potential problems or have any objections to my making 
this change?

Josh.
______________________________
 Josh Cates			
 Scientific Computing and Imaging Institute
 University of Utah
 Email: cates at sci . utah . edu
 Phone: (801) 587-7697
 URL:   http://www . sci . utah . edu/~cates