From 4e48b2bd88a018e6e9d383d07d9775f44b336e53 Mon Sep 17 00:00:00 2001 From: srit Date: Thu, 3 Mar 2011 13:26:49 +0000 Subject: [PATCH] Account for ITK image direction --- common/vvImage.txx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/vvImage.txx b/common/vvImage.txx index c0eda20..06f44af 100755 --- a/common/vvImage.txx +++ b/common/vvImage.txx @@ -4,6 +4,7 @@ template void vvImage::AddItkImage(TItkImageType *input) { + // Convert from ITK object to VTK object mImageDimension = TItkImageType::ImageDimension; typedef itk::ImageToVTKImageFilter 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; jGetImageDimension(); j++) + for(unsigned int i=0; iGetImageDimension(); i++) + mTransform->GetMatrix()->SetElement(i,j, input->GetDirection()[i][j]); + + // Create the corresponding transformed image mVtkImageReslice.push_back(vtkSmartPointer::New()); mVtkImageReslice.back()->SetInterpolationModeToLinear(); mVtkImageReslice.back()->AutoCropOutputOn(); -- 2.47.1