]> Creatis software - clitk.git/blobdiff - tools/clitkComposeVFGenericFilter.txx
ITK v4 compatibility
[clitk.git] / tools / clitkComposeVFGenericFilter.txx
old mode 100755 (executable)
new mode 100644 (file)
index 80d1d00..0e6d1a4
@@ -19,6 +19,7 @@
 #define __clitkComposeVFGenericFilter_txx
 #include "clitkComposeVFGenericFilter.h"
 
+#include "clitkConvertBLUTCoeffsToVFFilter.h"
 
 namespace clitk
 {
@@ -36,43 +37,58 @@ namespace clitk
       }
   }
 
-
+  
   template<unsigned int Dimension, class PixelType>
   void ComposeVFGenericFilter::UpdateWithDimAndPixelType()
   {
-
-    //Define the image type
     typedef itk::Vector<PixelType, Dimension> DisplacementType;
     typedef itk::Image<DisplacementType, Dimension> ImageType;
+    typename ImageType::Pointer input1, input2;
+
+    //Define the image type
+    if (m_Type == 1) {
+      typedef ConvertBLUTCoeffsToVFFilter<ImageType> VFFilterType;
+      typename VFFilterType::Pointer vf_filter = VFFilterType::New();
+      vf_filter->SetInputFileName(m_InputName1);
+      vf_filter->SetLikeFileName(m_LikeImage);
+      vf_filter->SetVerbose(m_Verbose);
+      vf_filter->Update();
+      input1 = vf_filter->GetOutput();
 
-    //Read the input1
-    typedef itk::ImageFileReader<ImageType> ImageReaderType;
-    typename  ImageReaderType::Pointer reader1= ImageReaderType::New();
-    reader1->SetFileName(m_InputName1);
-    reader1->Update();
-    typename ImageType::Pointer input1 =reader1->GetOutput();
-    //Read the input2
-    typename  ImageReaderType::Pointer reader2= ImageReaderType::New();
-    reader2->SetFileName(m_InputName2);
-    reader2->Update();
-    typename ImageType::Pointer input2=reader2->GetOutput();
+      vf_filter->SetInputFileName(m_InputName2);
+      vf_filter->Update();
+      input2 = vf_filter->GetOutput();
+    }
+    else {
+      //Read the input1
+      typedef itk::ImageFileReader<ImageType> ImageReaderType;
+      typename  ImageReaderType::Pointer reader1= ImageReaderType::New();
+      reader1->SetFileName(m_InputName1);
+      reader1->Update();
+      input1 =reader1->GetOutput();
 
-    //Create the ComposeVFFilter
-    typedef clitk::ComposeVFFilter<ImageType,ImageType> FilterType;
-    typename FilterType::Pointer filter =FilterType::New();
-    filter->SetInput1(input1);
-    filter->SetInput2(input2);
-    filter->SetVerbose(m_Verbose);
-    filter->Update();
-    
-    //Write the output
-    typedef itk::ImageFileWriter<ImageType> WriterType;
-    typename WriterType::Pointer writer = WriterType::New();
-    writer->SetFileName(m_OutputName);
-    writer->SetInput(filter->GetOutput());
-    writer->Update();
+      //Read the input2
+      typename  ImageReaderType::Pointer reader2= ImageReaderType::New();
+      reader2->SetFileName(m_InputName2);
+      reader2->Update();
+      input2=reader2->GetOutput();
+    }
 
+      //Create the ComposeVFFilter
+      typedef clitk::ComposeVFFilter<ImageType,ImageType> FilterType;
+      typename FilterType::Pointer filter =FilterType::New();
+      filter->SetInput1(input1);
+      filter->SetInput2(input2);
+      filter->SetVerbose(m_Verbose);
+      filter->Update();
+
+      //Write the output
+      typedef itk::ImageFileWriter<ImageType> WriterType;
+      typename WriterType::Pointer writer = WriterType::New();
+      writer->SetFileName(m_OutputName);
+      writer->SetInput(filter->GetOutput());
+      writer->Update();
+    
   }
 }