[vtkusers] image header size confusion
John Hunter
jdhunter at ace.bsd.uchicago.edu
Mon Jan 6 13:31:55 EST 2003
I am using vtkImageReader to read in some CT data, and am experiencing
some confusion over how to handle the header with vtk.
The data are 512 x 512 x 2bytes. To compute the header size, I take
the file size and subtract the number of pixels times the pixel size,
which is
529720 - 512*512*2 = 5432 bytes
When I load the file in matlab using these assumptions, it displays
properly. That is, I discard the first 5432 bytes of the file and
then read in the next 512*512 values as 2 byte unsigned ints.
However when I try to load it in vtk, I get a file load error when I
make the header size (with SetHeaderSize) larger than 3382 (which is
the value returned by GetHeaderSize if I do not set it manually). If
I use this default value, the data loads, but is skewed due to the
incorrect header size information.
So, what exactly is the HeaderSize in vtk, and how should I set it for
this file. Is it bytes from the beginning of the file to the pixel
data? The man pages for SetHeaderSize say
void SetHeaderSize (int size); If there is a tail on the file, you
want to explicitly set the header size.
which refers to a *tail*. This confuses me.
Here is the python code -- perhaps the values in the error message
will provide a clue.
# Image pipeline
reader = vtkImageReader()
reader.SetDataByteOrderToBigEndian()
reader.SetDataExtent(0,512,0,512,2,225)
reader.SetFilePrefix("Ser397")
reader.SetFilePattern("%s/I.%03d")
reader.SetDataScalarTypeToUnsignedShort()
reader.SetHeaderSize(5432)
Generic Warning: In /home/bellet/rpm/BUILD/VTK/IO/vtkImageReader.cxx, line 298
File operation failed. row = 0, Tried to Read = 1026, Read = 0, Skip0 = -2052, Skip1 = 1052676, FilePos = 530744
Guidance appreciated!
John Hunter
vtk nightly src from 2003-01-06 using vtkpython
More information about the vtkusers
mailing list