]> Creatis software - clitk.git/commitdiff
With ITKv5, change VectorResample and VectorCast Image Filter to Resample and Cast...
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Thu, 10 Oct 2019 07:15:00 +0000 (09:15 +0200)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Thu, 10 Oct 2019 07:15:00 +0000 (09:15 +0200)
I did not success to modify clitk::VectorBSplineInterpolateImageFunction according to this commit

registration/clitkGenericVectorInterpolator.h
registration/clitkGenericVectorInterpolator.txx
tools/clitkAffineTransformGenericFilter.h
tools/clitkAffineTransformGenericFilter.txx
tools/clitkImageConvertGenericFilter.h
tools/clitkInvertVFGenericFilter.txx
tools/clitkVFResampleGenericFilter.cxx
tools/clitkVFResampleGenericFilter.h
tools/clitkWarpImageGenericFilter.h
tools/clitkWarpImageGenericFilter.txx
vv/vvMidPosition.cxx

index 73bfa96b6b4360d9b71e7fd140b39b6c061ea732..e6aa7662cf461f00e01eab6ceb6dbbaba5f09c9a 100644 (file)
 #include "clitkImageCommon.h"
 
 //itk include
+#if ( ITK_VERSION_MAJOR < 5 )
 #include "itkVectorNearestNeighborInterpolateImageFunction.h"
 #include "itkVectorLinearInterpolateImageFunction.h"
+#else
+#include "itkNearestNeighborInterpolateImageFunction.h"
+#include "itkLinearInterpolateImageFunction.h"
+#endif
 #include "clitkVectorBSplineInterpolateImageFunction.h"
 #include "clitkVectorBSplineInterpolateImageFunctionWithLUT.h"
 
@@ -56,7 +61,11 @@ namespace clitk
     typedef itk::SmartPointer<Self>            Pointer;
     typedef itk::SmartPointer<const Self>      ConstPointer;
 
+#if ( ITK_VERSION_MAJOR < 5 )
     typedef itk::VectorInterpolateImageFunction<ImageType, TCoordRep> InterpolatorType;
+#else
+    typedef itk::InterpolateImageFunction<ImageType, TCoordRep> InterpolatorType;
+#endif
     typedef typename InterpolatorType::Pointer InterpolatorPointer;   
      
     /** Method for creation through the object factory. */
index 001399d833627eafe295d201933af597e867056f..cd9c0f76e1e28684b8f3e27335bce03385f58ba5 100644 (file)
@@ -48,17 +48,25 @@ namespace clitk
       {
       case 0: 
 
+#if ( ITK_VERSION_MAJOR < 5 )
        interpolator= itk::VectorNearestNeighborInterpolateImageFunction< ImageType,TCoordRep >::New();
+#else
+       interpolator= itk::NearestNeighborInterpolateImageFunction< ImageType,TCoordRep >::New();
+#endif
        if (m_Verbose) std::cout<<"Using nearestneighbor interpolation..."<<std::endl;
        break;
  
       case 1:
 
+#if ( ITK_VERSION_MAJOR < 5 )
        interpolator = itk::VectorLinearInterpolateImageFunction< ImageType,TCoordRep >::New();
+#else
+       interpolator = itk::LinearInterpolateImageFunction< ImageType,TCoordRep >::New();
+#endif
        if (m_Verbose) std::cout<<"Using linear interpolation..."<<std::endl;
        break;  
       
-      case 2:
+/*      case 2:
        {
          typename clitk::VectorBSplineInterpolateImageFunction< ImageType,TCoordRep >::Pointer m =clitk::VectorBSplineInterpolateImageFunction< ImageType,TCoordRep >::New();
          m->SetSplineOrder(m_ArgsInfo.interpVFOrder_arg);
@@ -76,7 +84,7 @@ namespace clitk
          if (m_Verbose) std::cout<<"Using BLUT interpolation..."<<std::endl;
          break;
        } 
-
+*/
       }//end of switch
     
     
index 482114b0adfd4d9e342855a7817c20cbdf8e1076..b4560b69062facdd58b4f09c7b62b6b4f12cae37 100644 (file)
@@ -40,7 +40,9 @@
 #include "itkLightObject.h"
 #include "itkAffineTransform.h"
 #include "itkResampleImageFilter.h"
+#if ( ITK_VERSION_MAJOR < 5 )
 #include "itkVectorResampleImageFilter.h"
+#endif
 
 
 namespace clitk 
index a3ec42038e431c41c909550e5ed6b4c6f2eaf70f..c1fe88a40f4d06d6a94ba34983cc3f958cad1ade 100644 (file)
@@ -711,7 +711,11 @@ namespace clitk
     }
 
     //Filter
+#if ( ITK_VERSION_MAJOR < 5 )
     typedef  itk::VectorResampleImageFilter< InputImageType,OutputImageType, double >  ResampleFilterType;
+#else
+    typedef  itk::ResampleImageFilter< InputImageType,OutputImageType, double >  ResampleFilterType;
+#endif
     typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();
 
     // Matrix
index 4f1a10031db0123b4ec7295f0ae19b6fe7dd98f5..a3174736ee7e878597fc143a1df88920f2fa8480 100644 (file)
@@ -32,7 +32,9 @@
 
 // itk include
 #include "itkCastImageFilter.h"
+#if ( ITK_VERSION_MAJOR < 5 )
 #include "itkVectorCastImageFilter.h"
+#endif
 
 
 namespace clitk {
@@ -208,7 +210,11 @@ namespace clitk {
 
         // Cast
         typedef itk::Image<itk::Vector<OutputPixelType, InputImageType::PixelType::Dimension>, InputImageType::ImageDimension> OutputImageType;
+#if ( ITK_VERSION_MAJOR < 5 )
         typedef itk::VectorCastImageFilter<InputImageType, OutputImageType> FilterType;
+#else
+        typedef itk::CastImageFilter<InputImageType, OutputImageType> FilterType;
+#endif
         typename FilterType::Pointer cast_filter = FilterType::New();
         cast_filter->SetInput(input);
         cast_filter->Update();
index 405540c41f4494b3e4c3c0749dbaab07f6f5673e..93ad21f9aca5c3862c5ec905bb70d5cbf9c97a1f 100644 (file)
 #ifndef clitkInvertVFGenericFilter_txx
 #define clitkInvertVFGenericFilter_txx
 
+#if ( ITK_VERSION_MAJOR < 5 )
 #include "itkVectorResampleImageFilter.h"
+#else
+#include "itkResampleImageFilter.h"
+#endif
 #include "clitkConvertBLUTCoeffsToVFFilter.h"
 
 /* =================================================
@@ -140,7 +144,11 @@ InvertVFGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
         spacing[i] = header->GetSpacing(i);
       }
 
+#if ( ITK_VERSION_MAJOR < 5 )
       typedef itk::VectorResampleImageFilter<InputImageType, OutputImageType> ResampleFilterType;
+#else
+      typedef itk::ResampleImageFilter<InputImageType, OutputImageType> ResampleFilterType;
+#endif
       typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();
       resampler->SetInput(input);
       resampler->SetOutputOrigin(input->GetOrigin());
index d287fec36e0b4047b64c7c5490b59536afcdb810..d60b8d0d9ae145a2effb3bf908eb998ae366a96d 100644 (file)
@@ -111,7 +111,11 @@ clitk::VFResampleGenericFilter::ComputeImage(typename ImageType::Pointer inputIm
   typedef typename ImageType::PointType PointType;
 
   // Create Image Filter
+#if ( ITK_VERSION_MAJOR < 5 )
   typedef itk::VectorResampleImageFilter<ImageType,ImageType> FilterType;
+#else
+  typedef itk::ResampleImageFilter<ImageType,ImageType> FilterType;
+#endif
   typename FilterType::Pointer filter = FilterType::New();
 
   // Instance of the transform object to be passed to the resample
@@ -137,12 +141,20 @@ clitk::VFResampleGenericFilter::ComputeImage(typename ImageType::Pointer inputIm
 
   // Select interpolator
   if (mInterpolatorName == "nn") {
+#if ( ITK_VERSION_MAJOR < 5 )
     typedef itk::VectorNearestNeighborInterpolateImageFunction<ImageType, double> InterpolatorType;
+#else
+    typedef itk::NearestNeighborInterpolateImageFunction<ImageType, double> InterpolatorType;
+#endif
     typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
     filter->SetInterpolator(interpolator);
   } else {
     if (mInterpolatorName == "linear") {
+#if ( ITK_VERSION_MAJOR < 5 )
       typedef itk::VectorLinearInterpolateImageFunction<ImageType, double> InterpolatorType;
+#else
+      typedef itk::LinearInterpolateImageFunction<ImageType, double> InterpolatorType;
+#endif
       typename InterpolatorType::Pointer interpolator =  InterpolatorType::New();
       filter->SetInterpolator(interpolator);
     } else {
index b4068826b072bcd22d355fa49a73eeede0ad517e..027be39d5d4014ea9fa90b135f4b94deb4b38553 100644 (file)
 #include "itkImageSeriesReader.h"
 #include "itkImageFileWriter.h"
 #include "itkRecursiveGaussianImageFilter.h"
+#if ( ITK_VERSION_MAJOR < 5 )
 #include "itkVectorResampleImageFilter.h"
-#include "itkAffineTransform.h"
 #include "itkVectorNearestNeighborInterpolateImageFunction.h"
 #include "itkVectorLinearInterpolateImageFunction.h"
+#else
+#include "itkResampleImageFilter.h"
+#include "itkNearestNeighborInterpolateImageFunction.h"
+#include "itkLinearInterpolateImageFunction.h"
+#endif
+#include "itkAffineTransform.h"
 #include "itkBSplineInterpolateImageFunction.h"
 #include "itkBSplineInterpolateImageFunctionWithLUT.h"
 #include "itkCommand.h"
index 0ce874deb74c26f8773f7f0438c7ce1efecd5fa0..58da907bf7ac3e488464aa0d71115c48540980ae 100644 (file)
 //itk include
 #include "itkLightObject.h"
 #include "itkWarpImageFilter.h"
+#if ( ITK_VERSION_MAJOR < 5 )
 #include "itkVectorResampleImageFilter.h"
+#else
+#include "itkResampleImageFilter.h"
+#endif
 
 namespace clitk 
 {
index 84bfbaaec7148cc5f133180c3b5290ca608eb491..c3f58b37d225dc41181009664831ea7f1f093808 100644 (file)
  *
  ===================================================*/
 
+#if ( ITK_VERSION_MAJOR < 5 )
 #include "itkVectorResampleImageFilter.h"
+#else
+#include "itkResampleImageFilter.h"
+#endif
 #include "clitkConvertBLUTCoeffsToVFFilter.h"
 
 namespace clitk
@@ -128,8 +132,13 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
     genericInterpolator->SetArgsInfo(m_ArgsInfo);
 
     // Resample to match the extent of the input
+#if ( ITK_VERSION_MAJOR < 5 )
     typename itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
     resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
+#else
+    typename itk::ResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
+    resampler =itk::ResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
+#endif
     resampler->SetInput(deformationField);
     resampler->SetOutputSpacing(deformationField->GetSpacing());
     resampler->SetOutputDirection(deformationField->GetDirection());
@@ -160,8 +169,13 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
       newSize[i]=input->GetLargestPossibleRegion().GetSize()[i];
 
     // Resample to match the extent of the input
+#if ( ITK_VERSION_MAJOR < 5 )
     typename itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
     resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
+#else
+    typename itk::ResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
+    resampler =itk::ResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
+#endif
     resampler->SetInput(deformationField);
     resampler->SetOutputSpacing(input->GetSpacing());
     resampler->SetOutputDirection(deformationField->GetDirection());
@@ -213,8 +227,13 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
     backwardWarpFilter->SetOutputOrigin( input->GetOrigin() );
     backwardWarpFilter->SetOutputSize( deformationField->GetLargestPossibleRegion().GetSize() );
     backwardWarpFilter->SetOutputDirection( input->GetDirection() );
+#if ( ITK_VERSION_MAJOR < 5 )
     typename itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
     resampler =itk::VectorResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
+#else
+    typename itk::ResampleImageFilter<DeformationFieldType, DeformationFieldType >::Pointer
+    resampler =itk::ResampleImageFilter<DeformationFieldType, DeformationFieldType >::New();
+#endif
     backwardWarpFilter->SetInterpolator(genericInterpolator->GetInterpolatorPointer());
     warpFilter=backwardWarpFilter;
   }
index d4192d601ed5877478671d0669e2607c2ca63cc0..ed5880b562fbc3c11e4ab9199a4eed14cc2e4332 100644 (file)
 #include <QApplication>
 
 #include <itkWarpImageFilter.h>
+#if ( ITK_VERSION_MAJOR < 5 )
 #include <itkVectorResampleImageFilter.h>
+#else
+#include <itkResampleImageFilter.h>
+#endif
 
 #include "vvMidPosition.h"
 #include "clitkCommon.h"
@@ -95,8 +99,13 @@ vvImage::Pointer WarpRefImage(OutputVFType::Pointer vf,vvImage::Pointer image,in
 
   //We resample the VF because itk's warp filter doesn't like it when the vf and the image have
   //different spacings
+#if ( ITK_VERSION_MAJOR < 5 )
   typename itk::VectorResampleImageFilter<OutputVFType, OutputVFType >::Pointer
   resampler =itk::VectorResampleImageFilter<OutputVFType, OutputVFType >::New();
+#else
+  typename itk::ResampleImageFilter<OutputVFType, OutputVFType >::Pointer
+  resampler =itk::ResampleImageFilter<OutputVFType, OutputVFType >::New();
+#endif
   resampler->SetInput(vf);
   resampler->SetOutputSpacing(input->GetSpacing());
   resampler->SetOutputOrigin(vf->GetOrigin());