[Insight-users] RawImageIO read failed

Luis Roberto P. Paula luisrpp at gmail.com
Mon Jul 19 23:07:52 EDT 2010


Hi All,

I need to read a 64x64x64 raw image, 32 bit float, Little Endian. To do that
I'm using itk::RawImageIO, but for some reason, I'm getting the following
runtime error:

   itk::ERROR: RawImageIO(0x1015af510): Read failed: Wanted 1048576 bytes,
but read 16384 bytes.

Does anyone know what might be happening?

Here is the code:
___________________________________________________

typedef float PixelType;
const unsigned int DIMENSION = 3;
typedef itk::Image< PixelType, DIMENSION >  ImageType;
typedef itk::ImageFileReader< ImageType  >  ReaderType;

int main( int argc, char ** argv )
{
char *inputFilename  = argv[1];

   itk::RawImageIO<PixelType, DIMENSION>::Pointer io;
   io = itk::RawImageIO<PixelType, DIMENSION>::New();

   io->SetFileName(inputFilename);
   int dim[DIMENSION] = {64, 64, 64};
   double spacing[DIMENSION] = {1.0, 1.0, 1.0};
   double origin[DIMENSION] = {0.0, 0.0, 0.0};
   for(unsigned int i=0; i < DIMENSION; i++) {
      io->SetDimensions(i,dim[i]);
      io->SetSpacing(i,spacing[i]);
      io->SetOrigin(i,origin[i]);
   }
   io->SetByteOrderToLittleEndian();
   io->SetComponentType(itk::ImageIOBase::FLOAT);
   io->SetPixelType(itk::ImageIOBase::SCALAR);
   io->SetNumberOfComponents(1);

   ReaderType::Pointer reader = ReaderType::New();
   reader->SetImageIO(io);
   reader->SetFileName( inputFilename );
   reader->Update();

   return EXIT_SUCCESS;
}
___________________________________________________

Thanks & Regards,
Luis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100720/e642b97c/attachment-0001.htm>


More information about the Insight-users mailing list