[Insight-users] MetaImage Problems

Jacob Boomgaarden boomgaar at arsc.edu
Wed Aug 4 14:59:05 EDT 2004


Hi all,

I am having problems with reading in a MetaImage into a
quick example program.

The code for my program is:

#include "itkImage.h"
#include "itkImageFileReader.h"


int main(int argc, char ** argv)
{

typedef unsigned char			PixelType;
const unsigned int			Dimension = 3;

typedef itk::Image< PixelType, Dimension >	ImageType;

typedef itk::ImageFileReader< ImageType >	ReaderType;

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

const char * inputfile = argv[1];
reader->SetFileName( inputfile );


// catch any errors
try
{
	reader->Update();
}
catch( itk::ExceptionObject &err )
{
	std::cout<< "Exception Caught!"<< std::endl;
	std::cout<< err << std::endl;
	return 1;
}

ImageType::Pointer thoraxImage = reader->GetOutput();
std::cout<<"All Done"<<std::endl;
return 0;
}



I pass as a command line argument a metaimage header
called "lungs.mhd" that looks like this:

ObjectType = Image
NDims = 3
DimSize = 512 315 20
ElementSpacing = 1 1 1
Position = 0 0 0
ElementByteOrderMSB = True
ElementType = MET_UCHAR
ElementDataFile = lungs.%03d 0 19 1

The images that make up the MetaImage are all PNG images
of 63.5 KB with size 512 X 315 and data type unsigned char.

The error messages I'm getting are:

  file = _lungs.000_
MetaImage: M_ReadElements: data not read completely
   ideal = 161280 : actual = 0

over the twenty images that I give it.

Thanks for the help.




More information about the Insight-users mailing list