[Insight-developers] file reader behavior

Luis Ibanez luis . ibanez at kitware . com
Wed, 07 Aug 2002 09:25:17 -0400


Hi Damion,

The code for MetaImage reader has been recently
reworked by UNC. It is possible that during this
process the management of MetaImageIO has being
modified to better match the style of the other
readers.

Both styles, the factory and the direct Set are correct
code. Factories are much more flexible since they let
you manage multiple file styles with the same code.
(for example the  GaussianFilter2D example can equally
read 2D MetaImages and PNG images).

The drawback of using the SetImageIO method directly
is that the ImageFileReader will only be able to read
this particular file format and nothing else.

We may want to make sure that the factory style
is always working. If it is failing, it could be related
to a problem recognizing the file format of the file.


  Luis

--
(BTW the MetaImage changes happened around monday
this week)


=================================================

Damion Shelton wrote:
> Quick question about image IO:
> 
> Until recently, the following code fragment worked fine.
> 
>  m_ImageReader = ImageFileReaderType::New();
>  itk::MetaImageIOFactory::RegisterOneFactory();
>  m_ImageReader->SetFileName( m_InputImageFilename );
>  m_InputImage = m_ImageReader->GetOutput();
>  m_InputImage->SetRequestedRegionToLargestPossibleRegion();
>  m_ImageReader->Update();
> 
> Now, this crashes, but rewriting it in a slightly different way works.
> 
>  m_ImageReader = ImageFileReaderType::New();
>  itk::MetaImageIO::Pointer metaIO;
>  metaIO = itk::MetaImageIO::New();
>  m_ImageReader->SetImageIO(metaIO);
>  m_ImageReader->SetFileName(m_InputImageFilename);
>  m_ImageReader->Update();
>  m_InputImage = m_ImageReader->GetOutput();
>  m_InputImage->SetRequestedRegionToLargestPossibleRegion();
> 
> Any ideas what's going on? The original code was very similar to 
> MetaImageIOTest while the new version is closer to most of the other 
> image tests (PNG, for instance). Which of the two styles (factory vs. 
> SetImageIO) is "correct"?
> 
> Thanks,
> -Damion-
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>