From: Simon Rit Date: Thu, 23 Jun 2011 11:16:58 +0000 (+0200) Subject: Account for itk origin when using itk direction to build vv transform X-Git-Tag: v1.3.0~312 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=13408338a1ef8779be07f538aacb787683aa5ddb;p=clitk.git Account for itk origin when using itk direction to build vv transform --- diff --git a/common/vvImage.txx b/common/vvImage.txx index 6e89076..90eeb02 100644 --- a/common/vvImage.txx +++ b/common/vvImage.txx @@ -26,21 +26,27 @@ void vvImage::AddItkImage(TItkImageType *input) input->Update(); // Convert from ITK object to VTK object - mImageDimension = TItkImageType::ImageDimension; + mImageDimension = TItkImageType::ImageDimension; typedef itk::ImageToVTKImageFilter ConverterType; typename ConverterType::Pointer converter = ConverterType::New(); mItkToVtkConverters.push_back(dynamic_cast< itk::ProcessObject *>(converter.GetPointer())); 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. vtkSmartPointer matrix = vtkSmartPointer::New(); matrix->Identity(); - for(unsigned int j=0; jGetImageDimension(); j++) - for(unsigned int i=0; iGetImageDimension(); i++) + for(unsigned int i=0; iGetImageDimension(); i++) { + for(unsigned int j=0; jGetImageDimension(); j++) { (*matrix)[i][j] = input->GetDirection()[i][j]; + // Direction is used around the image origin in ITK + (*matrix)[i][3] -= (*matrix)[i][j] * input->GetOrigin()[j]; + } + (*matrix)[i][3] += input->GetOrigin()[i]; + } + mTransform->SetMatrix(matrix); } //--------------------------------------------------------------------