[vtkusers] Reading vtk image files
Amy Henderson
amy.henderson at kitware.com
Tue Mar 18 08:44:08 EST 2003
At 02:50 PM 3/18/2003 +1100, Nerolie.Oakes at csiro.au wrote:
>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();
>
>
You need to call Reader->Update(); before you try to get information from
its output.
- Amy
>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/c19daa8d/attachment.htm>
More information about the vtkusers
mailing list