[vtkusers] Reading in legacy data

Budd Hirons bhiron at lsuhsc.edu
Fri Feb 14 12:01:37 EST 2003


the code below is what I use to load voxel data from a binary volume file 
with a header of 2048 bytes.  the header size does not matter if your 
extents are correct and there is no tail, I think the reader calcs offsets 
into the data file starting from the end of the volume file.  there may be 
better ways depending on your purpose, but this works fine for me.

         this->vr = vtkImageReader2::New();
         this->vr->SetDataByteOrderToLittleEndian();
         this->vr->SetDataScalarTypeToUnsignedChar();    //raw byte data
         this->vr->SetFileDimensionality(3);             //dimensions in file
         this->vr->SetFileName( volFile );
         this->vr->SetDataExtent( 0, widthBytes - 1,             //extent 
of data on disk
                                 0, heightBytes - 1,
                                 0, depthBytes - 1);
         this->vr->SetDataSpacing( widthVoxel, heightVoxel, depthVoxel );
         this->vr->SetFileLowerLeft( 1 );
         this->vr->Update();

Budd.

At 05:14 PM 2/14/2003 +0100, you wrote:
>On Fri, Feb 14, 2003 at 10:56:22AM -0500, Arun Nagarajan wrote:
> >  I have spent considerable time looking around trying to figure out vtk
> > reader class to use to do this properly. The basic fileformat of the 
> data we
> > have in the native binary format is: 52 bytes of header and then actual 3D
> > data in the row major form. I have looked at vtkVolumeReader, vtkDataReader
> > (and all of its subclasses),
> > vtkImageReader etc. But none of them striked as being the right one.. maybe
> > I actually need to play around with them...
>
>I can confirm that ONE of these three is EXACTLY what you're looking for. ;)
>
>--
>charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/




More information about the vtkusers mailing list