]> Creatis software - clitk.git/commitdiff
Account for ITK image direction
authorsrit <srit>
Thu, 3 Mar 2011 13:26:49 +0000 (13:26 +0000)
committersrit <srit>
Thu, 3 Mar 2011 13:26:49 +0000 (13:26 +0000)
common/vvImage.txx

index c0eda2082e75f756e44a7fa33caa828e8848e22b..06f44af400ef2d75dc0bb12936ed80289672d84f 100755 (executable)
@@ -4,6 +4,7 @@
 template<class TItkImageType>
 void vvImage::AddItkImage(TItkImageType *input)
 {
+  // Convert from ITK object to VTK object
   mImageDimension = TItkImageType::ImageDimension; 
   typedef itk::ImageToVTKImageFilter <TItkImageType> ConverterType;
   typename ConverterType::Pointer converter = ConverterType::New();
@@ -11,7 +12,14 @@ void vvImage::AddItkImage(TItkImageType *input)
   converter->SetInput(input);
   converter->Update();
   mVtkImages.push_back( converter->GetOutput() );
+  
+  // Account for direction in transform. The offset is already accounted for
+  // in the VTK image coordinates, no need to put it in the transform.
+  for(unsigned int j=0; j<input->GetImageDimension(); j++)
+    for(unsigned int i=0; i<input->GetImageDimension(); i++)
+      mTransform->GetMatrix()->SetElement(i,j, input->GetDirection()[i][j]);
+
+  // Create the corresponding transformed image
   mVtkImageReslice.push_back(vtkSmartPointer<vtkImageReslice>::New());
   mVtkImageReslice.back()->SetInterpolationModeToLinear();
   mVtkImageReslice.back()->AutoCropOutputOn();