]> Creatis software - clitk.git/blob - tools/clitkComposeVFGenericFilter.txx
changes in license header
[clitk.git] / tools / clitkComposeVFGenericFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef __clitkComposeVFGenericFilter_txx
19 #define __clitkComposeVFGenericFilter_txx
20 #include "clitkComposeVFGenericFilter.h"
21
22
23 namespace clitk
24 {
25
26   template<unsigned int Dimension>
27   void ComposeVFGenericFilter::UpdateWithDim(std::string PixelType)
28   {
29     if (PixelType=="double")
30       {
31         UpdateWithDimAndPixelType<Dimension, double>();
32       }     
33     else
34       {
35         UpdateWithDimAndPixelType<Dimension, float>();
36       }
37   }
38
39
40   template<unsigned int Dimension, class PixelType>
41   void ComposeVFGenericFilter::UpdateWithDimAndPixelType()
42   {
43
44     //Define the image type
45     typedef itk::Vector<PixelType, Dimension> DisplacementType;
46     typedef itk::Image<DisplacementType, Dimension> ImageType;
47
48     //Read the input1
49     typedef itk::ImageFileReader<ImageType> ImageReaderType;
50     typename  ImageReaderType::Pointer reader1= ImageReaderType::New();
51     reader1->SetFileName(m_InputName1);
52     reader1->Update();
53     typename ImageType::Pointer input1 =reader1->GetOutput();
54  
55     //Read the input2
56     typename  ImageReaderType::Pointer reader2= ImageReaderType::New();
57     reader2->SetFileName(m_InputName2);
58     reader2->Update();
59     typename ImageType::Pointer input2=reader2->GetOutput();
60
61     //Create the ComposeVFFilter
62     typedef clitk::ComposeVFFilter<ImageType,ImageType> FilterType;
63     typename FilterType::Pointer filter =FilterType::New();
64     filter->SetInput1(input1);
65     filter->SetInput2(input2);
66     filter->SetVerbose(m_Verbose);
67     filter->Update();
68     
69     //Write the output
70     typedef itk::ImageFileWriter<ImageType> WriterType;
71     typename WriterType::Pointer writer = WriterType::New();
72     writer->SetFileName(m_OutputName);
73     writer->SetInput(filter->GetOutput());
74     writer->Update();
75
76   }
77 }
78
79 #endif