]> Creatis software - clitk.git/blob - segmentation/clitkDecomposeAndReconstructImageFilter.txx
changes in license header
[clitk.git] / segmentation / clitkDecomposeAndReconstructImageFilter.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 clitkDecomposeAndReconstructImageFilter_txx
19 #define clitkDecomposeAndReconstructImageFilter_txx
20
21 namespace clitk
22 {
23
24   //-------------------------------------------------------------------
25   // Update with the number of dimensions
26   //-------------------------------------------------------------------
27   template<class InputImageType, class OutputImageType>
28   DecomposeAndReconstructImageFilter<InputImageType, OutputImageType>::DecomposeAndReconstructImageFilter()
29   {
30    m_Verbose=false;
31    for (unsigned int i=0; i<InputImageDimension; i++)
32      m_Radius[i]=1;
33    m_NumberOfNewLabels=1;
34    m_FullyConnected=true;
35    m_BackgroundValue=0;
36    m_ForegroundValue=1;
37    m_MaximumNumberOfLabels=10;
38    m_MinimumObjectSize=10;
39    m_MinimumNumberOfIterations=1;
40
41   }
42
43
44   //-------------------------------------------------------------------
45   // Update with the number of dimensions and the pixeltype
46   //-------------------------------------------------------------------
47   template <class InputImageType, class  OutputImageType> 
48   void 
49   DecomposeAndReconstructImageFilter<InputImageType, OutputImageType>::GenerateData()
50   {
51
52
53     // Internal type
54     typedef itk::Image<InternalPixelType, InputImageDimension> InternalImageType;
55
56     // Filters used
57     typedef clitk::DecomposeThroughErosionImageFilter<InputImageType, InternalImageType> DecomposeThroughErosionImageFilterType;
58     typedef clitk::ReconstructThroughDilationImageFilter<InternalImageType, InputImageType> ReconstructThroughDilationImageFilterType;
59
60     // Erode 
61     typename DecomposeThroughErosionImageFilterType::Pointer erosionFilter=DecomposeThroughErosionImageFilterType::New();
62     erosionFilter->SetInput(this->GetInput());
63     erosionFilter->SetVerbose(m_Verbose);
64     erosionFilter->SetFullyConnected(m_FullyConnected);
65     erosionFilter->SetRadius(m_Radius);
66     erosionFilter->SetNumberOfNewLabels(m_NumberOfNewLabels);
67     erosionFilter->SetMinimumObjectSize(m_MinimumObjectSize);
68     erosionFilter->SetMinimumNumberOfIterations(m_MinimumNumberOfIterations);
69     erosionFilter->Update();
70
71     // Reconstruct
72     typename ReconstructThroughDilationImageFilterType::Pointer reconstructionFilter =ReconstructThroughDilationImageFilterType::New();
73     reconstructionFilter->SetInput(erosionFilter->GetOutput());
74     reconstructionFilter->SetVerbose(m_Verbose);
75     reconstructionFilter->SetRadius(m_Radius);
76     reconstructionFilter->SetMaximumNumberOfLabels(m_MaximumNumberOfLabels);
77     reconstructionFilter->SetBackgroundValue(m_BackgroundValue);
78     reconstructionFilter->SetForegroundValue(m_ForegroundValue);
79     reconstructionFilter->Update();
80     
81     // Output
82     this->SetNthOutput(0,reconstructionFilter->GetOutput());
83   }
84
85
86 }//end clitk
87  
88 #endif //#define clitkDecomposeAndReconstructImageFilter_txx