[Insight-developers] file reader behavior

Stephen R. Aylward aylward at unc . edu
Wed, 07 Aug 2002 11:13:37 -0400


Hi,

I am doing the MetaImage update.  I have only added the new library - I 
have yet to switch ITK to using the new one instead of the old one - I 
may workup the nerve to do it today :)

s

Luis Ibanez wrote:

> 
> 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
>>
> 
> 
> 
> 


-- 
===============================================
Dr. Stephen R. Aylward
Assistant Professor of Radiology
Adjunct Assistant Professor of Computer Science
http://caddlab.rad.unc.edu
aylward@unc.edu
(919) 966-9695