[vtkusers] read Analyze files with VTK

Bryn Lloyd blloyd at vision.ee.ethz.ch
Tue Nov 24 03:51:01 EST 2009


Hi,

You can read it in Matlab, and write it to some format you can work with 
(Matlab Image Processing Toolbox has functions for reading analyze 
files. see analyze75read, analyze75info).


Otherwise Slicer3D can read analyze files, and I guess save them to 
different formats.
Internally it parses the header of the analyze file and uses 
vtkImageReader to read the data.



Something like this:

   vtkNew(vtkImageReader, reader);
   reader->SetFileName((inFilePrefix + ".img").c_str());
   if (analyzeheader->IsLittleEndian())
     reader->SetDataByteOrderToLittleEndian();
   reader->SetDataExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1);
   reader->SetDataSpacing(spacing[0], spacing[1], spacing[2]);
   reader->SetFileDimensionality(3);
   reader->SetScalarArrayName("data");
   switch (analyzeheader->GetDataType()) {
   case DT_DOUBLE:
     reader->SetDataScalarTypeToDouble();
     break;
   case DT_FLOAT:
     reader->SetDataScalarTypeToFloat();
     break;
   case DT_SIGNED_INT:
     reader->SetDataScalarTypeToInt();
     break;
   case DT_UNSIGNED_CHAR:
     reader->SetDataScalarTypeToUnsignedChar();
   case DT_SIGNED_SHORT:
     reader->SetDataScalarTypeToShort();
     break;
   default:
     cerr << "Warning: this data type is not expected." << endl;
   }
   // flip y-axis, seems to be standard for this format
   vtkNew(vtkImageFlip, flipper);
   flipper->SetInputConnection(reader->GetOutputPort());
   flipper->SetFilteredAxis(1);
   flipper->Update();













Srinivasa Rao Sunkara wrote:
> Hi,
> 
>    I would like to know how to read /Analyze image format  /using VTK. 
> Can someone help me regarding this?
> 
> Thanks
> 
> Srinivas
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 


-- 
-------------------------------------------------
Bryn Lloyd
Computer Vision Laboratory
ETH Zürich, Sternwartstrasse 7, ETF C110
CH - 8092 Zürich, Switzerland
Tel: +41 44 63 26668
Fax: +41 44 63 21199
-------------------------------------------------



More information about the vtkusers mailing list