[vtkusers] image header size confusion
Alyassin, Abdalmajeid M (Research)
alyassin at crd.ge.com
Mon Jan 6 13:59:46 EST 2003
If the CT data contains only header information + image data, you do NOT need to specify the header
size. However, you only need to specify the header size ONLY if the data contains a trailer. Try to
read the data without specifying the header size, if it does not look ok, then your data file
contains trailer information & therefore you need to specify exactly the header size.
Hope this helps
Abdalmajeid
-----Original Message-----
From: John Hunter [mailto:jdhunter at ace.bsd.uchicago.edu]
Sent: Monday, January 06, 2003 1:32 PM
To: VTK Users
Subject: [vtkusers] image header size confusion
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
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list