<br><font size=2 face="sans-serif">John...try</font>
<br>
<br><font size=2 face="Courier New">reader.SetDataExtent(0,511,0,511,2,225)</font>
<br>
<br><font size=2 face="Courier New">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 (-;</font>
<br>
<br><font size=2 face="Courier New">...john<br>
</font>
<br>
<br>
<br>
<br>
<table>
<tr valign=top>
<td><font size=6 color=red face="Times New Roman"><b>Internet Mail Message</b></font>
<br><font size=2 color=red face="sans-serif">Received from host: </font>
<td></table>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>John Hunter <jdhunter@ace.bsd.uchicago.edu></b></font>
<br><font size=1 face="sans-serif"> Sent by: vtkusers-admin@public.kitware.com</font>
<p><font size=1 face="sans-serif">01/06/2003 01:31 PM</font>
<br>
<td><font size=1 face="Arial"> </font>
<br><font size=1 face="sans-serif"> To: VTK Users <vtkusers@public.kitware.com></font>
<br><font size=1 face="sans-serif"> cc: (bcc: John Anast-JM/PGI)</font>
<br><font size=1 face="sans-serif"> Subject: [vtkusers] image header size confusion</font></table>
<br>
<br><font size=2 face="Courier New"><br>
I am using vtkImageReader to read in some CT data, and am experiencing<br>
some confusion over how to handle the header with vtk.<br>
<br>
The data are 512 x 512 x 2bytes. To compute the header size, I take<br>
the file size and subtract the number of pixels times the pixel size,<br>
which is<br>
<br>
529720 - 512*512*2 = 5432 bytes<br>
<br>
When I load the file in matlab using these assumptions, it displays<br>
properly. That is, I discard the first 5432 bytes of the file and<br>
then read in the next 512*512 values as 2 byte unsigned ints.<br>
<br>
However when I try to load it in vtk, I get a file load error when I<br>
make the header size (with SetHeaderSize) larger than 3382 (which is<br>
the value returned by GetHeaderSize if I do not set it manually). If<br>
I use this default value, the data loads, but is skewed due to the<br>
incorrect header size information.<br>
<br>
So, what exactly is the HeaderSize in vtk, and how should I set it for<br>
this file. Is it bytes from the beginning of the file to the pixel<br>
data? The man pages for SetHeaderSize say <br>
<br>
void SetHeaderSize (int size); If there is a tail on the file, you<br>
want to explicitly set the header size.<br>
<br>
which refers to a *tail*. This confuses me.<br>
<br>
<br>
Here is the python code -- perhaps the values in the error message<br>
will provide a clue.<br>
<br>
# Image pipeline<br>
reader = vtkImageReader()<br>
reader.SetDataByteOrderToBigEndian()<br>
reader.SetDataExtent(0,512,0,512,2,225)<br>
<br>
reader.SetFilePrefix("Ser397")<br>
reader.SetFilePattern("%s/I.%03d")<br>
reader.SetDataScalarTypeToUnsignedShort()<br>
reader.SetHeaderSize(5432)<br>
<br>
Generic Warning: In /home/bellet/rpm/BUILD/VTK/IO/vtkImageReader.cxx, line 298<br>
File operation failed. row = 0, Tried to Read = 1026, Read = 0, Skip0 = -2052, Skip1 = 1052676, FilePos = 530744<br>
</font>
<br><font size=2 face="Courier New">Guidance appreciated!<br>
John Hunter<br>
<br>
vtk nightly src from 2003-01-06 using vtkpython<br>
_______________________________________________<br>
This is the private VTK discussion list. <br>
Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq><br>
Follow this link to subscribe/unsubscribe:<br>
http://public.kitware.com/mailman/listinfo/vtkusers<br>
</font>
<br>
<br>