[Insight-developers] ImageFileReader and IO factory

Luis Ibanez luis . ibanez at kitware . com
Wed, 06 Aug 2003 17:48:09 -0400


Hi Josh,

The change looks good,

Just please add an initialization to false for
the m_UserSpecifiedImageIO flag in the constructor.

We probably need a similar modification in
the ImageFileWriter.



   Luis


-------------------
Joshua Cates wrote:
> 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
> 
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk . org
> http://www . itk . org/mailman/listinfo/insight-developers
>