]> Creatis software - clitk.git/blob - segmentation/clitkExtractMediastinumFilter.h
separate airway tracking from extract lung
[clitk.git] / segmentation / clitkExtractMediastinumFilter.h
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://oncora1.lyon.fnclcc.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
19 #ifndef CLITKEXTRACTMEDIASTINUMFILTER_H
20 #define CLITKEXTRACTMEDIASTINUMFILTER_H
21
22 #include "clitkFilterBase.h"
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
24
25 namespace clitk {
26   
27   //--------------------------------------------------------------------
28   /*
29     Try to extract the mediastinum part of a thorax CT.
30     Inputs : 
31     - Patient label image
32     - Lungs label image
33     - Bones label image
34     - Trachea label image
35   */
36   //--------------------------------------------------------------------
37   
38   template <class TImageType>
39   class ITK_EXPORT ExtractMediastinumFilter: 
40     public virtual clitk::FilterBase, 
41     public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
42     public itk::ImageToImageFilter<TImageType, TImageType> 
43   {
44
45   public:
46     /** Standard class typedefs. */
47     typedef itk::ImageToImageFilter<TImageType, TImageType> Superclass;
48     typedef ExtractMediastinumFilter            Self;
49     typedef itk::SmartPointer<Self>             Pointer;
50     typedef itk::SmartPointer<const Self>       ConstPointer;
51     
52     /** Method for creation through the object factory. */
53     itkNewMacro(Self);
54     
55     /** Run-time type information (and related methods). */
56     itkTypeMacro(ExtractMediastinumFilter, InPlaceImageFilter);
57     FILTERBASE_INIT;
58
59     /** Some convenient typedefs. */
60     typedef TImageType                       ImageType;
61     typedef typename ImageType::ConstPointer ImageConstPointer;
62     typedef typename ImageType::Pointer      ImagePointer;
63     typedef typename ImageType::RegionType   ImageRegionType; 
64     typedef typename ImageType::PixelType    ImagePixelType; 
65     typedef typename ImageType::SizeType     ImageSizeType; 
66     typedef typename ImageType::IndexType    ImageIndexType; 
67     typedef typename ImageType::PointType    ImagePointType; 
68         
69     /** Connect inputs */
70     void SetInputPatientLabelImage(const TImageType * image, ImagePixelType bg=0);
71     void SetInputLungLabelImage(const TImageType * image, ImagePixelType bg=0, 
72                                  ImagePixelType fgLeftLung=1, ImagePixelType fgRightLung=2);
73     void SetInputBonesLabelImage(const TImageType * image, ImagePixelType bg=0);
74     void SetInputTracheaLabelImage(const TImageType * image, ImagePixelType bg=0);
75    
76     /** ImageDimension constants */
77     itkStaticConstMacro(ImageDimension, unsigned int, TImageType::ImageDimension);
78
79     // Set all options at a time
80     template<class ArgsInfoType>
81       void SetArgsInfo(ArgsInfoType arg);
82    
83     // Background / Foreground
84     itkSetMacro(BackgroundValuePatient, ImagePixelType);
85     itkGetConstMacro(BackgroundValuePatient, ImagePixelType);
86     GGO_DefineOption(patientBG, SetBackgroundValuePatient, ImagePixelType);
87     
88     itkSetMacro(BackgroundValueLung, ImagePixelType);
89     itkGetConstMacro(BackgroundValueLung, ImagePixelType);
90     GGO_DefineOption(lungBG, SetBackgroundValueLung, ImagePixelType);
91     
92     itkSetMacro(BackgroundValueBones, ImagePixelType);
93     itkGetConstMacro(BackgroundValueBones, ImagePixelType);
94     GGO_DefineOption(bonesBG, SetBackgroundValueBones, ImagePixelType);
95     
96     itkGetConstMacro(BackgroundValue, ImagePixelType);
97     itkGetConstMacro(ForegroundValue, ImagePixelType);
98
99     itkSetMacro(ForegroundValueLeftLung, ImagePixelType);
100     itkGetConstMacro(ForegroundValueLeftLung, ImagePixelType);
101     GGO_DefineOption(lungLeft, SetForegroundValueLeftLung, ImagePixelType);
102     
103     itkSetMacro(ForegroundValueRightLung, ImagePixelType);
104     itkGetConstMacro(ForegroundValueRightLung, ImagePixelType);
105     GGO_DefineOption(lungRight, SetForegroundValueRightLung, ImagePixelType);
106     
107     itkSetMacro(BackgroundValueTrachea, ImagePixelType);
108     itkGetConstMacro(BackgroundValueTrachea, ImagePixelType);
109     GGO_DefineOption(lungBG, SetBackgroundValueTrachea, ImagePixelType);
110     
111     itkSetMacro(IntermediateSpacing, double);
112     itkGetConstMacro(IntermediateSpacing, double);
113     GGO_DefineOption(spacing, SetIntermediateSpacing, double);
114
115     itkSetMacro(FuzzyThreshold1, double);
116     itkGetConstMacro(FuzzyThreshold1, double);
117     GGO_DefineOption(fuzzy1, SetFuzzyThreshold1, double);
118
119     itkSetMacro(FuzzyThreshold2, double);
120     itkGetConstMacro(FuzzyThreshold2, double);
121     GGO_DefineOption(fuzzy2, SetFuzzyThreshold2, double);
122
123     itkSetMacro(FuzzyThreshold3, double);
124     itkGetConstMacro(FuzzyThreshold3, double);
125     GGO_DefineOption(fuzzy3, SetFuzzyThreshold3, double);
126
127   protected:
128     ExtractMediastinumFilter();
129     virtual ~ExtractMediastinumFilter() {}
130     
131     virtual void GenerateOutputInformation();
132     virtual void GenerateInputRequestedRegion();
133     virtual void GenerateData();
134        
135     itkSetMacro(BackgroundValue, ImagePixelType);
136     itkSetMacro(ForegroundValue, ImagePixelType);
137     
138     ImagePixelType m_BackgroundValuePatient;
139     ImagePixelType m_BackgroundValueLung;
140     ImagePixelType m_BackgroundValueBones;
141     ImagePixelType m_BackgroundValueTrachea;
142     ImagePixelType m_ForegroundValueLeftLung;
143     ImagePixelType m_ForegroundValueRightLung;
144
145     ImagePixelType m_BackgroundValue;
146     ImagePixelType m_ForegroundValue;
147     
148     double m_IntermediateSpacing;
149     double m_FuzzyThreshold1;
150     double m_FuzzyThreshold2;
151     double m_FuzzyThreshold3;
152     
153   private:
154     ExtractMediastinumFilter(const Self&); //purposely not implemented
155     void operator=(const Self&); //purposely not implemented
156     
157   }; // end class
158   //--------------------------------------------------------------------
159
160 } // end namespace clitk
161 //--------------------------------------------------------------------
162
163 #ifndef ITK_MANUAL_INSTANTIATION
164 #include "clitkExtractMediastinumFilter.txx"
165 #endif
166
167 #endif