[Insight-users] problems reading meta headers???

Luis Ibanez luis.ibanez@kitware.com
Thu, 27 Mar 2003 17:48:47 -0500


Hi Fernando,

You are missing to call Update() in the reader.


The output of the reader is not valid until you
call Update() in the reader, only at that point
your file will be read into memory.

Please do something like:

imageReader->SetFileName( argv[1] );

imageReader->Update();

 ImageType::Pointer myimage = imageReader->GetOutput();

---

You may want to read chapter 6 of the SoftwareGuide

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

in order to avoid similar problems,



Regards,


   Luis

---------------------------------------------
Fernando Rannou wrote:

> Hello,
>
> I'm having problems to manipulate meta images.
> Here is the header file:
>
> ObjectType = Image
> NDims = 3
> BinaryData = True
> BinaryDataByteOrderMSB = False
> ElementSpacing = 0.4 0.4 1.22
> DimSize = 128 128 63
> ElementType = MET_FLOAT
> ElementDataFile = rp_pet.mhd.raw
>
>
> and here's my program that prints out the image spacing:
> #include "itkImage.h"
> #include "itkImageFileReader.h"
>
> int main( int argc, char **argv )
> {
>  const   unsigned int  Dimension = 3;
>  typedef float         PixelType;
>
>  typedef itk::Image< PixelType, Dimension > ImageType;
>  typedef itk::ImageFileReader< ImageType  > ImageReaderType;
>
>  ImageReaderType::Pointer imageReader = ImageReaderType::New();
>
>  imageReader->SetFileName( argv[1] );
>
>  ImageType::Pointer myimage = imageReader->GetOutput();
>  const double * spacing = myimage->GetSpacing();
>  std::cout << "Spacing: " << spacing[0] << ", " << spacing[1] << ", " 
> << spacing[2] << std::endl;
>  return 0;
> }
>
>
> When I run the program I get:
>
> Spacing: 1, 1, 1
> ----
>
> This is probably something very obvious but I don't see it right now.
> Thanks
>
> Fernando
>
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>