[Insight-users] MetaImage

Luis Ibanez luis . ibanez at kitware . com
Thu, 12 Jun 2003 21:59:53 -0400


Hi Anouk,

You don't need to do this by yourself.

The ImageFileReader<> filter will do all this directly.
http://public . kitware . com/Insight/Doxygen/html/classitk_1_1ImageFileReader . html

Simply instantiate an image with a pixel type
that is capable of receiving the numerical values
stored in the actual image file.  Then, instantiate
an image file reader.

The whole code will look like:

typedef   unsigned short  PixelType;
typedef   itk::Image< PixelType, 3 > ImageType;
typedef   itk::ImageFileReader< ImageType > ReaderType;

ReaderType::Pointer reader = ReaderType::New();

reader->SetFileName("myImageFile.mha");
reader->Update();

ImageType::ConstPointer image = reader->GetOutput();


"image" will contain at this point the data read
from your MetaImage file.

You will find details about ITK's IO architecture
in the Chapter 6 of the SoftwareGuide, pdf-page 159.

     http://www . itk . org/ItkSoftwareGuide . pdf


The associated examples can be found in the directory

         Insitht/Examples/IO

--


  Regards,


     Luis


----------------------------------
Anouk Stein M.D. wrote:
> Dear ITK users group,
>  
> I'm trying to use the info from a metaImage file to instantiate Image<> 
> .  The element type in the header is listed as MET_SHORT which is a
> 
> MET_ValueEnumType which is also what MetaImage::ElementType() returns. 
> How do I convert this to a typename so that
> 
> typedef itk::Image <TPixel, dimensions> ImageType recognizes it?
> 
> Also I would like to use the number of dimensions from the header but 
> it's a protected member. What do you think I should do? Thankyou,
> 
> Anouk Stein
>