[Insight-users] Writing Meta files

Luis Ibanez luis . ibanez at kitware . com
Mon, 12 Aug 2002 10:44:19 -0400


Hi Zein,

There is currently an asymmetry in the way reading
and writing is managed.

For reading, the IO Factories are identifiying and
providing the apropiate ImageIO object that actually
performs the reading.

For writing, the user is currently responsible for
providing such ImageIO object. This will be corected
in the near future. Factories should be able to guess
an apropiate ImageIO object by looking at filename
extensions.

For the moment, if you need to write images the
following code is the typical way to go:

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

#include <itkMetaImageIO.h>
#include <itkImageFileWriter.h>

typedef itk::Image<char,3> ImageType;
typedef itk::ImageFileWriter<
                        ImageType > VolumeWriterType;

VolumeWriterType::Pointer writer = VolumeWriterType::New();
writer->SetImageIO( itk::MetaImageIO::New() );
writer->SetInput( ... put some image pointer here... );
writer->SetFilename( "image.mha" );
writer->Update();

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

Please let us know if you encounter further problems
writing images.

Thanks

Luis

=-=============================================
Zein Salah wrote:
> Hello friends,
> 
>  
> 
> I need to save volume data in meta files. The volume data was read 
> initially from a meta file.
> 
> I have written a program that just reads a volume from a meta file and 
> saves it into a new file name.
> 
> for reading, I have used the follwing classes
> 
> #include <itkImageFileReader.h>
> 
> #include <itkMetaImageIOFactory.h>
> 
>  
> 
> The program could read correctly.
> 
>  
> 
> I tried to used ther same manner for writing, i.e.
> 
> #include <itkImageFileWriter.h>
> 
> The program always generates the error message shown in the attached file.
> 
>  
> 
>  Do anybody has idea what is the problem.
> 
>  
> 
> I tried ro run the Gausian filter example to see how it saves images. It 
> reads files, applies fileter and show images correctly.  But It could 
> not save result files to disk. It always terminates abnormally.
> 
>  
> 
>  
> 
> Thanks in advanced for any help!
> 
>  
> 
> Zein
> 
>  
> 
>  
> 
> ->8<------------->8<------------->8<------------->8<------------->8<------------->8<-
> Zein I. Salah
> Universität Tübingen, WSI-GRIS
> Sand 14
> 72076 Tübingen
> Email: salah@gris.uni-tuebingen.de <mailto:salah@gris.uni-tuebingen.de>  
> / zeinsalah@hotmail.com <mailto:zeinsalah@hotmail.com>
> Tel.: (07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat)
>