]> Creatis software - clitk.git/blobdiff - tools/clitkWarpImageGenericFilter.txx
Add comment to precise the functionality of the inputs
[clitk.git] / tools / clitkWarpImageGenericFilter.txx
index 4c30c4c6b44e0632a5cf804be43d9a8e7fa778a9..84bfbaaec7148cc5f133180c3b5290ca608eb491 100644 (file)
@@ -28,7 +28,7 @@
  ===================================================*/
 
 #include "itkVectorResampleImageFilter.h"
-#include "clitkCoeffsToDVF.h"
+#include "clitkConvertBLUTCoeffsToVFFilter.h"
 
 namespace clitk
 {
@@ -90,7 +90,13 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
   
   typename DeformationFieldType::Pointer deformationField;
   if (m_ArgsInfo.coeff_given) {
-    deformationField = BLUTCoeffsToDVF<DeformationFieldType>(m_ArgsInfo.coeff_arg, m_InputFileName, m_Verbose);
+    typedef ConvertBLUTCoeffsToVFFilter<DeformationFieldType> FilterType;
+    typename FilterType::Pointer filter = FilterType::New();
+    filter->SetInputFileName(m_ArgsInfo.coeff_arg);
+    filter->SetLikeFileName(m_InputFileName);
+    filter->SetVerbose(m_Verbose);
+    filter->Update();
+    deformationField = filter->GetOutput();
   }
   else {
     //Read the deformation field
@@ -126,6 +132,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
     resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
     resampler->SetInput(deformationField);
     resampler->SetOutputSpacing(deformationField->GetSpacing());
+    resampler->SetOutputDirection(deformationField->GetDirection());
     resampler->SetSize(newSize);
     resampler->SetOutputOrigin(input->GetOrigin());
     resampler->SetInterpolator(genericInterpolator->GetInterpolatorPointer());
@@ -157,6 +164,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
     resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
     resampler->SetInput(deformationField);
     resampler->SetOutputSpacing(input->GetSpacing());
+    resampler->SetOutputDirection(deformationField->GetDirection());
     resampler->SetSize(newSize);
     resampler->SetOutputOrigin(input->GetOrigin());
     resampler->SetInterpolator(genericInterpolator->GetInterpolatorPointer());
@@ -199,15 +207,12 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
     //Backward mapping
     typedef itk::WarpImageFilter<InputImageType, InputImageType, DeformationFieldType> BackwardWarpFilterType;
     typename BackwardWarpFilterType::Pointer backwardWarpFilter= BackwardWarpFilterType::New();
-#if ITK_VERSION_MAJOR >= 4
     backwardWarpFilter->SetDisplacementField( deformationField );
-#else
-    backwardWarpFilter->SetDeformationField( deformationField );
-#endif
     backwardWarpFilter->SetEdgePaddingValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
     backwardWarpFilter->SetOutputSpacing( deformationField->GetSpacing() );
     backwardWarpFilter->SetOutputOrigin( input->GetOrigin() );
     backwardWarpFilter->SetOutputSize( deformationField->GetLargestPossibleRegion().GetSize() );
+    backwardWarpFilter->SetOutputDirection( input->GetDirection() );
     typename itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
     resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
     backwardWarpFilter->SetInterpolator(genericInterpolator->GetInterpolatorPointer());