1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
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"
26 //=========================================================================================================================
27 // DifferenceImageFilter
28 //=========================================================================================================================
30 //=========================================================================================================================
32 template <class InputImageType, class OutputImageType>
33 DifferenceImageFilter<InputImageType, OutputImageType>::DifferenceImageFilter()
35 this->SetNumberOfRequiredInputs(2);
38 //=========================================================================================================================
40 template <class InputImageType, class OutputImageType>
41 void DifferenceImageFilter<InputImageType, OutputImageType>::SetValidInput(const typename InputImageType::Pointer input)
43 this->SetNthInput(0,input);
46 template <class InputImageType, class OutputImageType>
47 void DifferenceImageFilter<InputImageType, OutputImageType>::SetTestInput(const typename InputImageType::Pointer input)
49 this->SetNthInput(1,input);
53 //=========================================================================================================================
55 template <class InputImageType, class OutputImageType>
56 void DifferenceImageFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType &threadRegion, int threadId)
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();
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();
73 while (!outputIterator.IsAtEnd())
75 outputIterator.Set(input1Iterator.Get()-input2Iterator.Get());