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