[Insight-users] Default orientation of an Analyze image

wenjia wenjia at robots.ox.ac.uk
Sat Aug 15 10:15:17 EDT 2009


Dear all,

I have just found that when ITK reads an Analyze image with unknown orientation, it does not set the default image direction to identity. Instead, it sets the direction to 

 [1 0 0
  0 0 -1
  0 1 0].

I am wondering why it uses this direction as default. Is this direction defined in any Analyze format standard? Is it possible to change the default to an identity matrix since it is easy to cope with?

I have put a test Analyze file on the website: http://www.robots.ox.ac.uk/~wenjia/data/

In addition, my ITK version is 3.14. I am using the following code for reading the direction,

#include "itkImage.h"
#include "itkImageFileReader.h"

int main(int argc, char *argv[])
{
  // Check the number of input arguments
  if(argc < 2){
    std::cout << "Read an image and show its direction" << std::endl;
    std::cout << "Usage: " << argv[0] << " image" << std::endl;
    return -1;
  }

  const char *filename = argv[1];

  // Read the image
  const unsigned int Dimension = 3;
  typedef double InternalPixelType;
  typedef itk::Image<InternalPixelType, Dimension> ImageType;
  typedef itk::ImageFileReader<ImageType> ImageReaderType;

  ImageReaderType::Pointer reader = ImageReaderType::New();
  reader->SetFileName(filename);
  reader->Update();
  ImageType::Pointer image = reader->GetOutput();

  // Show the direction
  std::cout << "The image direction is:" << std::endl;
  std::cout << image->GetDirection() << std::endl;

  return 0;
}


Many thanks,
Wenjia
-- 
Wenjia Bai
D.Phil Student
Wolfson Medical Vision Laboratory
Department of Engineering
University of Oxford


More information about the Insight-users mailing list