[vtkusers] image header size confusion

anast.jm at pg.com anast.jm at pg.com
Mon Jan 6 13:46:01 EST 2003


John...try

reader.SetDataExtent(0,511,0,511,2,225)

the real tip is that the file is 529720 long and the reader error was at 
position 530744, obviously trying to read past the end of the file ....0,512 is 513 
(-;

...john





Internet Mail Message
Received from host: 



John Hunter <jdhunter at ace.bsd.uchicago.edu>
                        Sent by: vtkusers-admin at public.kitware.com
01/06/2003 01:31 PM

 
               To:      VTK Users <vtkusers at public.kitware.com>
        cc:     (bcc: John Anast-JM/PGI)
        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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030106/0feeea81/attachment.htm>


More information about the vtkusers mailing list