]> Creatis software - clitk.git/blob - segmentation/clitkExtractMediastinumFilter.h
411e20f9a012f16dee145f44f5767ce9b50d0787
[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, itk::Image<uchar, 3> > 
43   {
44
45   public:
46     /** Some convenient typedefs. */
47     typedef TImageType                       ImageType;
48     typedef typename ImageType::ConstPointer ImageConstPointer;
49     typedef typename ImageType::Pointer      ImagePointer;
50     typedef typename ImageType::RegionType   ImageRegionType; 
51     typedef typename ImageType::PixelType    ImagePixelType; 
52     typedef typename ImageType::SizeType     ImageSizeType; 
53     typedef typename ImageType::IndexType    ImageIndexType; 
54     typedef typename ImageType::PointType    ImagePointType; 
55         
56     /** Some convenient typedefs. */
57     typedef uchar MaskImagePixelType; 
58     typedef itk::Image<MaskImagePixelType, 3>    MaskImageType;
59     typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
60     typedef typename MaskImageType::Pointer      MaskImagePointer;
61     typedef typename MaskImageType::RegionType   MaskImageRegionType; 
62     typedef typename MaskImageType::SizeType     MaskImageSizeType; 
63     typedef typename MaskImageType::IndexType    MaskImageIndexType; 
64     typedef typename MaskImageType::PointType    MaskImagePointType; 
65         
66     /** Standard class typedefs. */
67     typedef itk::ImageToImageFilter<TImageType, MaskImageType> Superclass;
68     typedef ExtractMediastinumFilter            Self;
69     typedef itk::SmartPointer<Self>             Pointer;
70     typedef itk::SmartPointer<const Self>       ConstPointer;
71     
72     /** Method for creation through the object factory. */
73     itkNewMacro(Self);
74     
75     /** Run-time type information (and related methods). */
76     itkTypeMacro(ExtractMediastinumFilter, InPlaceImageFilter);
77     FILTERBASE_INIT;
78
79     /** Connect inputs */
80     void SetInput(const ImageType * image);
81     void SetInputPatientLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
82     void SetInputLungLabelImage(const MaskImageType * image, MaskImagePixelType bg=0, 
83                                 MaskImagePixelType fgLeftLung=1, MaskImagePixelType fgRightLung=2);
84     void SetInputBonesLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
85     void SetInputTracheaLabelImage(const MaskImageType * image, MaskImagePixelType bg=0);
86    
87    // Output filename  (for AFBD)
88     itkSetMacro(OutputMediastinumFilename, std::string);
89     itkGetConstMacro(OutputMediastinumFilename, std::string);
90
91     /** ImageDimension constants */
92     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
93
94     // Background / Foreground
95     itkSetMacro(BackgroundValuePatient, MaskImagePixelType);
96     itkGetConstMacro(BackgroundValuePatient, MaskImagePixelType);
97     
98     itkSetMacro(BackgroundValueLung, MaskImagePixelType);
99     itkGetConstMacro(BackgroundValueLung, MaskImagePixelType);
100     
101     itkSetMacro(BackgroundValueBones, MaskImagePixelType);
102     itkGetConstMacro(BackgroundValueBones, MaskImagePixelType);
103     
104     itkGetConstMacro(BackgroundValue, MaskImagePixelType);
105     itkGetConstMacro(ForegroundValue, MaskImagePixelType);
106
107     itkSetMacro(ForegroundValueLeftLung, MaskImagePixelType);
108     itkGetConstMacro(ForegroundValueLeftLung, MaskImagePixelType);
109     
110     itkSetMacro(ForegroundValueRightLung, MaskImagePixelType);
111     itkGetConstMacro(ForegroundValueRightLung, MaskImagePixelType);
112     
113     itkSetMacro(BackgroundValueTrachea, MaskImagePixelType);
114     itkGetConstMacro(BackgroundValueTrachea, MaskImagePixelType);
115     
116     itkSetMacro(IntermediateSpacing, double);
117     itkGetConstMacro(IntermediateSpacing, double);
118
119     itkSetMacro(FuzzyThreshold1, double);
120     itkGetConstMacro(FuzzyThreshold1, double);
121
122     itkSetMacro(FuzzyThreshold2, double);
123     itkGetConstMacro(FuzzyThreshold2, double);
124
125     itkSetMacro(FuzzyThreshold3, double);
126     itkGetConstMacro(FuzzyThreshold3, double);
127
128     itkBooleanMacro(UseBones);
129     itkSetMacro(UseBones, bool);
130     itkGetConstMacro(UseBones, bool);
131
132     itkSetMacro(UpperThreshold, double);
133     itkGetConstMacro(UpperThreshold, double);
134
135     itkSetMacro(LowerThreshold, double);
136     itkGetConstMacro(LowerThreshold, double);
137
138   protected:
139     ExtractMediastinumFilter();
140     virtual ~ExtractMediastinumFilter() {}
141     
142     virtual void GenerateOutputInformation();
143     virtual void GenerateInputRequestedRegion();
144     virtual void GenerateData();
145        
146     itkSetMacro(BackgroundValue, MaskImagePixelType);
147     itkSetMacro(ForegroundValue, MaskImagePixelType);
148     
149     MaskImagePixelType m_BackgroundValuePatient;
150     MaskImagePixelType m_BackgroundValueLung;
151     MaskImagePixelType m_BackgroundValueBones;
152     MaskImagePixelType m_BackgroundValueTrachea;
153     MaskImagePixelType m_ForegroundValueLeftLung;
154     MaskImagePixelType m_ForegroundValueRightLung;
155
156     MaskImagePixelType m_BackgroundValue;
157     MaskImagePixelType m_ForegroundValue;
158
159     typename MaskImageType::Pointer output;
160
161     double m_IntermediateSpacing;
162     double m_FuzzyThreshold1;
163     double m_FuzzyThreshold2;
164     double m_FuzzyThreshold3;
165     bool   m_UseBones;
166     double m_UpperThreshold;
167     double m_LowerThreshold;
168     
169     std::string m_OutputMediastinumFilename;
170     
171   private:
172     ExtractMediastinumFilter(const Self&); //purposely not implemented
173     void operator=(const Self&); //purposely not implemented
174     
175   }; // end class
176   //--------------------------------------------------------------------
177
178 } // end namespace clitk
179 //--------------------------------------------------------------------
180
181 #ifndef ITK_MANUAL_INSTANTIATION
182 #include "clitkExtractMediastinumFilter.txx"
183 #endif
184
185 #endif