[vtkusers] VTK File format: Little/big endian problem [or] looking for a VTK guru...
Dave Semeraro
semeraro at ncsa.uiuc.edu
Tue Mar 18 11:00:26 EST 2003
Hi Mathieu,
I feel your pain. I too battled to make sense of the endian thing. I work
on Intel machines and
so the words are little endian. I believe VTK by default assumes data is
big endian. Therefore,
I found that when I tried to read binary vtk files that I had created the
vtkDataReader merrily
swapped the bytes for me producing interesting results. In my particular
case I was reading
vtkRectilinearGrids. I think any reader that uses the vtkDataReader class
will produce similar
results. I had two choices. I could swap the bytes before I created the vtk
files or I could skip
the vtk file reading and build a vtk data set by reading the data and
packing it into vtkFloatArrays.
I chose the later as being the path of least resistance. Another
possibility is to force the
definition of VTK_WORDS_BIGENDIAN in the vtkConfigure.h file and recompile.
That is not a
very good option in my opinion.
I realize none of this solves your problem. I find it helps me to hear
others have had similar
experiences.
Regards,
Dave
At 10:24 AM 3/17/2003 +0100, Mathieu Malaterre wrote:
>Hi all,
>
> I would like to know when working on an intel plateform in what
> kind of endianess Binary VTK Structured Points files are stored ?
>
> I am working on a Linux OS with AMD processors, and I have found
> that my binary files are stored in Big Endian...
> According to : http://public.kitware.com/VTK/pdf/file-formats.pdf
> I should have Little endian files, right ?
>
>---
>
>I check what cmake had found:
>
>$ grep ENDIAN VTKBin/CMakeCache.txt
>CMAKE_WORDS_BIGENDIAN:INTERNAL=0
>HAVE_CMAKE_WORDS_BIGENDIAN:INTERNAL=TRUE
>
>---
>
>I also put on my web page the files that I used for checking this
>little/big endian problem. For _courageous_ people you'll find them here:
>
> http://www.creatis.insa-lyon.fr/~malaterre/vtk/endian/
>
>Where you'll find:
>
>- phantom_FLw.raw, comes from Insight ftp web directory :
>ftp://public.kitware.com/pub/itk/Data/MultiChannelMSPhantomData/Phantom/phantom_FLw.zip
>
>- ReadMe.txt, describe the file format.
>
>- read.py, is a python script that allow user to read this raw file
>
>- phantom_FLw.mha, this is a MetaIO header files that allow ITK user to
>easily read phantom_FLw.raw
>
>- phantom_FLw_LE.raw, is the Little Endian version of phantom_FLw.raw
>
>- phantom_FLw_LE.mha, is again the MetaIO header associated.
>
>- phantom_FLw.vtk, comes from phantom_FLw.raw <- Big Endian
>
>- phantom_FLw_LE.vtk, comes from phantom_FLw_LE.raw <- Little Endian
>
>---
>
> If you diff phantom_FLw.vtk phantom_FLw_LE.vtk you'll see there
> is absolutely no difference. And when you use hexedit (or hexdiff) you'll
> see that both vtk files are in Big Endian (while comparing to
>phantom_FLw.raw)...
> Be aware that I didn't used read.py to output the VTK files as it
> writes COLOR_SCALARS instead of SCALARS thus it didn't allow direct
>comparison between VTK and RAW files...I used instead an ITK tool
>therefore you only need to delete the first 10 lines of each VTK file to
>compare to the raw one.
>
>---
>
> For normal people, could they try to load these VTK files (gzip
> files are provided to ease downloading) and tell me if the VTK files
> works (on what kind of OS = Little/Big endian), please. You should see a
> phantom that mimic the MS lesions in brain MR scans (see MSLesion.png for
> rough idea).
> In case there is a little genious around (or someone with lots of
> time to waste...) could he told me why I got Big Endian files on my
> Little Endian system ???
>
>
>Thank you all,
>mathieu...banging his head against the wall...
>
>
>--
>Mathieu Malaterre
>CREATIS
>28 Avenue du Doyen LEPINE
>B.P. Lyon-Montchat
>69394 Lyon Cedex 03
>http://www.creatis.insa-lyon.fr/~malaterre/
>
>
>
>_______________________________________________
>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
Dave Semeraro Ph.D.
Visualization and Virtual Environments Group
NCSA University of Illinois
605 E. Springfield Ave.
Champaign, IL 61820
Semeraro at ncsa.uiuc.edu
(217) 244-1852
More information about the vtkusers
mailing list