]> Creatis software - clitk.git/blob - segmentation/clitkExtractMediastinalVesselsFilter.h
44bb53af2fe267e2d9a6b3db6a62efe81b477616
[clitk.git] / segmentation / clitkExtractMediastinalVesselsFilter.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 CLITKEXTRACTLYMPHSTATIONSFILTER_H
20 #define CLITKEXTRACTLYMPHSTATIONSFILTER_H
21
22 // clitk
23 #include "clitkFilterBase.h"
24 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
25
26 namespace clitk {
27   
28   //--------------------------------------------------------------------
29   /*
30     Try to extract the some Mediastinal Vessels in a thorax CT.
31     Need a set of Anatomical Features (AFDB)
32   */
33   //--------------------------------------------------------------------
34   
35   template <class TImageType>
36   class ITK_EXPORT ExtractMediastinalVesselsFilter: 
37     public virtual clitk::FilterBase, 
38     public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
39     public itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> >
40   {
41
42   public:
43     /** Standard class typedefs. */
44     typedef itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> > Superclass;
45     typedef ExtractMediastinalVesselsFilter          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(ExtractMediastinalVesselsFilter, ImageToImageFilter);
54
55     /** Some convenient typedefs. */
56     typedef TImageType                       ImageType;
57     typedef typename ImageType::ConstPointer ImageConstPointer;
58     typedef typename ImageType::Pointer      ImagePointer;
59     typedef typename ImageType::RegionType   ImageRegionType; 
60     typedef typename ImageType::PixelType    ImagePixelType; 
61     typedef typename ImageType::SizeType     ImageSizeType; 
62     typedef typename ImageType::IndexType    ImageIndexType; 
63     typedef typename ImageType::PointType    ImagePointType; 
64         
65     typedef uchar MaskImagePixelType;
66     typedef itk::Image<MaskImagePixelType, 3>    MaskImageType;  
67     typedef typename MaskImageType::Pointer      MaskImagePointer;
68     typedef typename MaskImageType::RegionType   MaskImageRegionType; 
69     typedef typename MaskImageType::SizeType     MaskImageSizeType; 
70     typedef typename MaskImageType::IndexType    MaskImageIndexType; 
71     typedef typename MaskImageType::PointType    MaskImagePointType; 
72
73     typedef itk::Image<MaskImagePixelType, 2>    MaskSliceType;
74     typedef typename MaskSliceType::Pointer      MaskSlicePointer;
75     typedef typename MaskSliceType::PointType    MaskSlicePointType;
76
77     typedef long LabelType;
78     /** ImageDimension constants */
79     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
80     FILTERBASE_INIT;
81    
82     itkGetConstMacro(BackgroundValue, MaskImagePixelType);
83     itkSetMacro(BackgroundValue, MaskImagePixelType);
84
85     itkGetConstMacro(ForegroundValue, MaskImagePixelType);
86     itkSetMacro(ForegroundValue, MaskImagePixelType);
87
88     itkGetConstMacro(TemporaryForegroundValue, MaskImagePixelType);
89     itkSetMacro(TemporaryForegroundValue, MaskImagePixelType);
90
91     itkGetConstMacro(ThresholdHigh, ImagePixelType);
92     itkSetMacro(ThresholdHigh, ImagePixelType);
93
94     itkGetConstMacro(ThresholdLow, ImagePixelType);
95     itkSetMacro(ThresholdLow, ImagePixelType);
96
97     itkGetConstMacro(ErosionRadius, int);
98     itkSetMacro(ErosionRadius, int);
99
100     itkGetConstMacro(DilatationRadius, int);
101     itkSetMacro(DilatationRadius, int);
102
103     itkGetConstMacro(MaxDistancePostToCarina, double);
104     itkSetMacro(MaxDistancePostToCarina, double);
105     itkGetConstMacro(MaxDistanceAntToCarina, double);
106     itkSetMacro(MaxDistanceAntToCarina, double);
107     itkGetConstMacro(MaxDistanceLeftToCarina, double);
108     itkSetMacro(MaxDistanceLeftToCarina, double);
109     itkGetConstMacro(MaxDistanceRightToCarina, double);
110     itkSetMacro(MaxDistanceRightToCarina, double);
111
112     itkSetMacro(DebugFlag, bool);
113     itkGetConstMacro(DebugFlag, bool);
114     itkBooleanMacro(DebugFlag);
115
116     itkSetMacro(SoughtVesselSeedName, std::string);
117     itkGetConstMacro(SoughtVesselSeedName, std::string);
118
119     itkSetMacro(SoughtVesselName, std::string);
120     itkGetConstMacro(SoughtVesselName, std::string);
121
122     itkSetMacro(OutputFilename, std::string);
123     itkGetConstMacro(OutputFilename, std::string);
124
125     itkSetMacro(MaxNumberOfFoundBifurcation, int);
126     itkGetConstMacro(MaxNumberOfFoundBifurcation, int);
127
128     itkSetMacro(FinalOpeningRadius, int);
129     itkGetConstMacro(FinalOpeningRadius, int);
130
131   protected:
132     ExtractMediastinalVesselsFilter();
133     virtual ~ExtractMediastinalVesselsFilter() {}
134     
135     virtual void GenerateOutputInformation();
136     virtual void GenerateInputRequestedRegion();
137     virtual void GenerateData();
138     
139     bool               m_DebugFlag;
140     ImagePointer       m_Input;
141     MaskImagePointer   m_Working_Support;
142     MaskImagePointer   m_Mediastinum;
143     MaskImagePointer   m_Mask;
144     MaskImagePixelType m_BackgroundValue;
145     MaskImagePixelType m_ForegroundValue;
146     MaskImagePixelType m_TemporaryForegroundValue;
147     ImagePixelType     m_ThresholdHigh;
148     ImagePixelType     m_ThresholdLow;
149     int                m_ErosionRadius;
150     int                m_DilatationRadius;
151     double             m_MaxDistancePostToCarina;
152     double             m_MaxDistanceAntToCarina;
153     double             m_MaxDistanceLeftToCarina;
154     double             m_MaxDistanceRightToCarina;
155     int                m_MaxNumberOfFoundBifurcation;
156     int                m_FinalOpeningRadius;
157
158     std::vector<MaskSlicePointer> m_slice_recon;
159     std::vector<MaskSlicePointer> m_slice_recon2;
160     
161     // Resulting structures
162     MaskImageType::Pointer m_SoughtVessel;
163     std::string m_SoughtVesselSeedName;
164     std::string m_SoughtVesselName;
165     std::string m_OutputFilename;
166     
167     void CropInputImage();
168     void TrackBifurcationFromPoint(MaskImagePointer & recon, 
169                                    std::vector<MaskSlicePointer> & slices_recon, 
170                                    MaskImagePointType point3D,
171                                    MaskImagePointType pointMaxSlice,
172                                    LabelType newLabel, 
173                                    std::vector<MaskImagePointType> & bif);
174
175     void TrackVesselsFromPoint(MaskImagePointer & recon, 
176                                std::vector<MaskSlicePointer> & slices_recon, 
177                                MaskImagePointType point3D,
178                                MaskImagePointType pointMaxSlice,
179                                LabelType newLabel);
180     
181   private:
182     ExtractMediastinalVesselsFilter(const Self&); //purposely not implemented
183     void operator=(const Self&); //purposely not implemented
184     
185   }; // end class
186   //--------------------------------------------------------------------
187
188 } // end namespace clitk
189 //--------------------------------------------------------------------
190
191 #ifndef ITK_MANUAL_INSTANTIATION
192 #include "clitkExtractMediastinalVesselsFilter.txx"
193 #endif
194
195 #endif