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