]> Creatis software - clitk.git/blob - segmentation/clitkExtractMediastinalVesselsFilter.h
itk4 migration
[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(VerboseTrackingFlag, bool);
117     itkGetConstMacro(VerboseTrackingFlag, bool);
118     itkBooleanMacro(VerboseTrackingFlag);
119
120     itkSetMacro(SoughtVesselSeedName, std::string);
121     itkGetConstMacro(SoughtVesselSeedName, std::string);
122
123     itkSetMacro(SoughtVesselName, std::string);
124     itkGetConstMacro(SoughtVesselName, std::string);
125
126     itkSetMacro(OutputFilename, std::string);
127     itkGetConstMacro(OutputFilename, std::string);
128
129     itkSetMacro(MaxNumberOfFoundBifurcation, int);
130     itkGetConstMacro(MaxNumberOfFoundBifurcation, int);
131
132     itkSetMacro(FinalOpeningRadius, int);
133     itkGetConstMacro(FinalOpeningRadius, int);
134
135   protected:
136     ExtractMediastinalVesselsFilter();
137     virtual ~ExtractMediastinalVesselsFilter() {}
138     
139     virtual void GenerateOutputInformation();
140     virtual void GenerateInputRequestedRegion();
141     virtual void GenerateData();
142     
143     bool               m_DebugFlag;
144     bool               m_VerboseTrackingFlag;
145     ImagePointer       m_Input;
146     MaskImagePointer   m_Working_Support;
147     MaskImagePointer   m_Mediastinum;
148     MaskImagePointer   m_Mask;
149     MaskImagePixelType m_BackgroundValue;
150     MaskImagePixelType m_ForegroundValue;
151     MaskImagePixelType m_TemporaryForegroundValue;
152     ImagePixelType     m_ThresholdHigh;
153     ImagePixelType     m_ThresholdLow;
154     int                m_ErosionRadius;
155     int                m_DilatationRadius;
156     double             m_MaxDistancePostToCarina;
157     double             m_MaxDistanceAntToCarina;
158     double             m_MaxDistanceLeftToCarina;
159     double             m_MaxDistanceRightToCarina;
160     int                m_MaxNumberOfFoundBifurcation;
161     int                m_FinalOpeningRadius;
162
163     std::vector<MaskSlicePointer> m_slice_recon;
164     std::vector<MaskSlicePointer> m_slice_recon2;
165     
166     // Resulting structures
167     MaskImageType::Pointer m_SoughtVessel;
168     std::string m_SoughtVesselSeedName;
169     std::string m_SoughtVesselName;
170     std::string m_OutputFilename;
171     
172     void CropInputImage();
173     void TrackBifurcationFromPoint(MaskImagePointer & recon, 
174                                    std::vector<MaskSlicePointer> & slices_recon, 
175                                    MaskImagePointType point3D,
176                                    MaskImagePointType pointMaxSlice,
177                                    LabelType newLabel, 
178                                    std::vector<MaskImagePointType> & bif);
179
180     void TrackVesselsFromPoint(MaskImagePointer & recon, 
181                                std::vector<MaskSlicePointer> & slices_recon, 
182                                MaskImagePointType point3D,
183                                MaskImagePointType pointMaxSlice,
184                                LabelType newLabel);
185     
186   private:
187     ExtractMediastinalVesselsFilter(const Self&); //purposely not implemented
188     void operator=(const Self&); //purposely not implemented
189     
190   }; // end class
191   //--------------------------------------------------------------------
192
193 } // end namespace clitk
194 //--------------------------------------------------------------------
195
196 #ifndef ITK_MANUAL_INSTANTIATION
197 #include "clitkExtractMediastinalVesselsFilter.txx"
198 #endif
199
200 #endif