Coordinate System Conversion Between ITK and Slicer3

From NAMIC Wiki
Revision as of 21:59, 22 March 2007 by Vmagnotta (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Coordinate System Conversion Between ITK and Slicer3
 DirectionType imageDir;
 PointType origin;
 
 int dominantAxisRL = itk::Function::Max3(imageDir[0][0],imageDir[1][0],imageDir[2][0]);
 int signRL = itk::Function::Sign(imageDir[dominantAxisRL][0]);
 int dominantAxisAP = itk::Function::Max3(imageDir[0][1],imageDir[1][1],imageDir[2][1]);
 int signAP = itk::Function::Sign(imageDir[dominantAxisAP][1]);
 int dominantAxisSI = itk::Function::Max3(imageDir[0][2],imageDir[1][2],imageDir[2][2]);
 int signSI = itk::Function::Sign(imageDir[dominantAxisSI][2]);
 
 DirectionType DirectionToRAS;
 DirectionToRAS.SetIdentity( );
 
 if (signRL == 1)
   {
     DirectionToRAS[dominantAxisRL][dominantAxisRL] = -1.0; 
     origin[dominantAxisRL] *= -1.0;
   }
 if (signAP == -1)
   {
     DirectionToRAS[dominantAxisAP][dominantAxisAP] = -1.0; 
     origin[dominantAxisAP] *= -1.0;
   }
 if (signSI == 1)
   {
     DirectionToRAS[dominantAxisSI][dominantAxisSI] = -1.0; 
     origin[dominantAxisSI] *= -1.0;
   }
 
 imageDir *= DirectionToRAS;
 /* Set the Image Coordinate Frame */