]> Creatis software - clitk.git/blob - itk/clitkDecomposeAndReconstructImageFilter.txx
Debug RTStruct conversion with empty struc
[clitk.git] / itk / 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 /* =================================================
22  * @file   clitkDecomposeAndReconstructImageFilter.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, class OutputImageType>
38   DecomposeAndReconstructImageFilter<InputImageType, OutputImageType>::DecomposeAndReconstructImageFilter()
39   {
40    m_Verbose=false;
41    for (unsigned int i=0; i<InputImageDimension; i++)
42      m_Radius[i]=1;
43    m_NumberOfNewLabels=1;
44    m_FullyConnected=true;
45    m_BackgroundValue=0;
46    m_ForegroundValue=1;
47    m_MaximumNumberOfLabels=10;
48    m_MinimumObjectSize=10;
49    m_MinimumNumberOfIterations=1;
50
51   }
52
53
54   //-------------------------------------------------------------------
55   // Update with the number of dimensions and the pixeltype
56   //-------------------------------------------------------------------
57   template <class InputImageType, class  OutputImageType> 
58   void 
59   DecomposeAndReconstructImageFilter<InputImageType, OutputImageType>::GenerateData()
60   {
61
62
63     // Internal type
64     typedef itk::Image<InternalPixelType, InputImageDimension> InternalImageType;
65
66     // Filters used
67     typedef clitk::DecomposeThroughErosionImageFilter<InputImageType, InternalImageType> DecomposeThroughErosionImageFilterType;
68     typedef clitk::ReconstructThroughDilationImageFilter<InternalImageType, InputImageType> ReconstructThroughDilationImageFilterType;
69
70     // Erode 
71     typename DecomposeThroughErosionImageFilterType::Pointer erosionFilter=DecomposeThroughErosionImageFilterType::New();
72     erosionFilter->SetInput(this->GetInput());
73     erosionFilter->SetVerbose(m_Verbose);
74     erosionFilter->SetFullyConnected(m_FullyConnected);
75     erosionFilter->SetRadius(m_Radius);
76     erosionFilter->SetNumberOfNewLabels(m_NumberOfNewLabels);
77     erosionFilter->SetMinimumObjectSize(m_MinimumObjectSize);
78     erosionFilter->SetMinimumNumberOfIterations(m_MinimumNumberOfIterations);
79     erosionFilter->Update();
80
81     // Reconstruct
82     typename ReconstructThroughDilationImageFilterType::Pointer reconstructionFilter =ReconstructThroughDilationImageFilterType::New();
83     reconstructionFilter->SetInput(erosionFilter->GetOutput());
84     reconstructionFilter->SetVerbose(m_Verbose);
85     reconstructionFilter->SetRadius(m_Radius);
86     reconstructionFilter->SetMaximumNumberOfLabels(m_MaximumNumberOfLabels);
87     reconstructionFilter->SetBackgroundValue(m_BackgroundValue);
88     reconstructionFilter->SetForegroundValue(m_ForegroundValue);
89     reconstructionFilter->Update();
90     
91     // Output
92     this->SetNthOutput(0,reconstructionFilter->GetOutput());
93   }
94
95
96 }//end clitk
97  
98 #endif //#define clitkDecomposeAndReconstructImageFilter_txx