]> Creatis software - clitk.git/blob - registration/clitkDifferenceImageFilter.txx
Debug RTStruct conversion with empty struc
[clitk.git] / registration / clitkDifferenceImageFilter.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 __clitkDifferenceImageFilter_txx
19 #define __clitkDifferenceImageFilter_txx
20 #include "clitkDifferenceImageFilter.h"
21
22
23 namespace clitk
24 {
25
26   //=========================================================================================================================
27   // DifferenceImageFilter
28   //=========================================================================================================================
29
30   //=========================================================================================================================
31   //constructor
32   template <class InputImageType, class OutputImageType> 
33   DifferenceImageFilter<InputImageType, OutputImageType>::DifferenceImageFilter()
34   {
35     this->SetNumberOfRequiredInputs(2);
36   }
37
38   //=========================================================================================================================
39   //set input
40   template <class InputImageType, class OutputImageType> 
41   void DifferenceImageFilter<InputImageType, OutputImageType>::SetValidInput(const typename InputImageType::Pointer input)
42   {
43     this->SetNthInput(0,input);
44   }
45
46   template <class InputImageType, class OutputImageType> 
47   void DifferenceImageFilter<InputImageType, OutputImageType>::SetTestInput(const typename InputImageType::Pointer input)
48   {
49     this->SetNthInput(1,input);
50   }
51
52
53   //=========================================================================================================================
54   //Update
55   template <class InputImageType, class OutputImageType> 
56   void DifferenceImageFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType &threadRegion, int threadId)
57   {
58     //Pointers to input and output
59     typename InputImageType::ConstPointer input1=this->GetInput(0);
60     typename InputImageType::ConstPointer input2=this->GetInput(1);
61     typename OutputImageType::Pointer output=this->GetOutput();
62
63     //Iterator over input1, input0 and output
64     typedef itk::ImageRegionConstIterator<InputImageType> InputIteratortype;
65     typedef itk::ImageRegionIterator<OutputImageType> OutputIteratortype;
66     InputIteratortype input1Iterator (input1, threadRegion);
67     InputIteratortype input2Iterator (input2, threadRegion);
68     OutputIteratortype outputIterator (output, threadRegion);
69     input1Iterator.GoToBegin();
70     input2Iterator.GoToBegin();
71     outputIterator.GoToBegin();
72
73     while (!outputIterator.IsAtEnd())
74       {
75         outputIterator.Set(input1Iterator.Get()-input2Iterator.Get());
76         ++input1Iterator;
77         ++input2Iterator;
78         ++outputIterator;        
79       }
80   }
81       
82 }
83
84
85 #endif