[Insight-users] RawImageIO read failed

Luis Roberto P. Paula luisrpp at gmail.com
Tue Jul 20 00:28:52 EDT 2010


Hi Robert,

I was able to open the same file in ImageJ using the following parameters:

Image Type: 32-bit Real
Width: 64 pixels
Height: 64 pixels
Number of images: 64
Little-Endian Byte Order

I don't know why RawImageIO is saying that there is just 16384 bytes,

Thanks & Regards,
Luis

On Tue, Jul 20, 2010 at 1:13 AM, robert tamburo <robert.tamburo at gmail.com>wrote:

> Your image parameters yield an expected file size larger than that of the
> file you are trying to read, i.e., 64*64*64*32/8 = 1048576 bytes when your
> file is only 16384 bytes.
>
> On Mon, Jul 19, 2010 at 11:07 PM, Luis Roberto P. Paula <luisrpp at gmail.com
> > wrote:
>
>> 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
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100720/5c9b5a1b/attachment.htm>


More information about the Insight-users mailing list