]> Creatis software - clitk.git/blob - tools/clitkCombineImageFilter.txx
8a4f0514e39a9ac82b8ddcaa5de6d12f9ce72add
[clitk.git] / tools / clitkCombineImageFilter.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 clitkCombineImageFilter_txx
19 #define clitkCombineImageFilter_txx
20
21 /* =================================================
22  * @file   clitkCombineImageFilter.txx
23  * @author 
24  * @date   
25  * 
26  * @brief 
27  * 
28  ===================================================*/
29
30
31 namespace clitk
32 {
33
34   //-------------------------------------------------------------------
35   // Update with the number of dimensions
36   //-------------------------------------------------------------------
37   template<class InputImageType>
38   CombineImageFilter<InputImageType>::CombineImageFilter()
39   {
40    m_Verbose=false;
41   }
42
43
44   //-------------------------------------------------------------------
45   // Update with the number of dimensions and the pixeltype
46   //-------------------------------------------------------------------
47   template<class InputImageType> 
48   void 
49   CombineImageFilter<InputImageType>::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId)
50   {
51     typename InputImageType::ConstPointer input1=this->GetInput(0);
52     typename InputImageType::ConstPointer input2=this->GetInput(1);
53     typename InputImageType::Pointer output=this->GetOutput();
54
55     typedef itk::ImageRegionIterator<InputImageType> IteratorType;
56     typedef itk::ImageRegionConstIterator<InputImageType> ConstIteratorType;
57     typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType;
58     
59     ConstIteratorType it1(input1, outputRegionForThread);
60     ConstIteratorType it2(input2, outputRegionForThread);
61     MaskIteratorType itM(m_Mask, outputRegionForThread);
62     IteratorType itO(output, outputRegionForThread);
63
64     it1.GoToBegin();
65     it2.GoToBegin();
66     itM.GoToBegin();
67     itO.GoToBegin();
68
69     while(! itO.IsAtEnd())
70       {
71         if(itM.Get())
72           itO.Set(it1.Get());
73         else
74           itO.Set(it2.Get());
75         
76         ++it1;
77         ++it2;
78         ++itM;
79         ++itO;
80       }
81
82  }
83
84
85 }//end clitk
86  
87 #endif //#define clitkCombineImageFilter_txx