[vtkusers] Reading vtk image files

Nerolie.Oakes at csiro.au Nerolie.Oakes at csiro.au
Mon Mar 17 22:50:38 EST 2003


I am attempting to read in an existing file in vtk format. I want to convert
it
To my own format, and hence need to get the image dimensions etc.
 
I've tried the following, but am not getting sensible results (ie not in
dataSet or imageData):
 
vtkDataSetReader *Reader = vtkDataSetReader::New();
            Reader->SetFileName(filename);
            vtkDataSet *dataSet = (vtkDataSet*)vtkDataSet::New();
            dataSet = Reader->GetOutput(); 
            float *bounds = dataSet->GetBounds();
also
 
vtkStructuredPointsReader *Reader = vtkStructuredPointsReader::New();
            Reader->SetFileName(filename);
            vtkStructuredPoints *dataSet = vtkStructuredPoints::New();
            dataSet = Reader->GetOutput();
            vtkImageData *imageData = Reader->GetOutput();
            float *bounds = dataSet->GetBounds();
            int *dim = dataSet->GetDimensions();
 
I realise I'm doing something fundamentally wrong, but I'm not sure what,
and I can't
Seem to find an example that helps. Can anyone help? (Perhaps my
expectations are
Wrong - for example, how should I extract the numbers 512 486 and 41 if not
from
A call to GetDimensions?)
 
 
The file in question has header
 
# vtk DataFile Version 2.0
comments here
BINARY
DATASET STRUCTURED_POINTS
DIMENSIONS 512 486 41
ORIGIN 0 0 0
SPACING 0.51 1.62 24.39
POINT_DATA 10202112
SCALARS scalars unsigned_short
LOOKUP_TABLE default
 
And I can read it in OK via a sample program (which however passes a
vtkDataSetReader  object's output straight to  a vtkDataSetMapper, rather
than extracting values
directly).
 
Thanks in advance,
Nerolie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030318/cd190a8c/attachment.htm>


More information about the vtkusers mailing list