]> Creatis software - clitk.git/blobdiff - segmentation/clitkExtractLungFilter.h
move clitkConfiguration.h out of clitkCommon to avoid costly recompilations
[clitk.git] / segmentation / clitkExtractLungFilter.h
index c62afe527066816da79fd6bc43c2611bea7c9ed4..6ec698d3a204bc98dddd17190dafa44ba8e83209 100644 (file)
@@ -54,30 +54,10 @@ namespace clitk {
   */
   //--------------------------------------------------------------------
   
-
-  //--------------------------------------------------------------------
-template<class IndexType, class PixelType>
-class Bifurcation
-{
-public:
-  Bifurcation(IndexType _index, PixelType _l, PixelType _l1, PixelType _l2) {
-    index = _index;
-    _l = l;
-    _l1 = l1;
-    _l2 = l2;
-  }
-  IndexType index;
-  PixelType l;
-  PixelType l1;
-  PixelType l2;
-};
-  //--------------------------------------------------------------------
-
-
   //--------------------------------------------------------------------
   template <class TImageType, class TMaskImageType>
   class ITK_EXPORT ExtractLungFilter: 
-    public clitk::FilterBase, 
+    public virtual clitk::FilterBase, 
     public itk::ImageToImageFilter<TImageType, TMaskImageType> 
   {
     
@@ -103,6 +83,7 @@ public:
     typedef typename ImageType::PixelType    InputImagePixelType; 
     typedef typename ImageType::SizeType     InputImageSizeType; 
     typedef typename ImageType::IndexType    InputImageIndexType; 
+    typedef typename ImageType::PointType    InputImagePointType; 
         
     typedef TMaskImageType                       MaskImageType;
     typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
@@ -111,6 +92,7 @@ public:
     typedef typename MaskImageType::PixelType    MaskImagePixelType; 
     typedef typename MaskImageType::SizeType     MaskImageSizeType; 
     typedef typename MaskImageType::IndexType    MaskImageIndexType; 
+    typedef typename MaskImageType::PointType    MaskImagePointType; 
 
     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
     typedef int InternalPixelType;
@@ -147,6 +129,10 @@ public:
     itkGetConstMacro(UpperThreshold, InputImagePixelType);
     GGO_DefineOption(upper, SetUpperThreshold, InputImagePixelType);
 
+    itkSetMacro(NumberOfSlicesToSkipBeforeSearchingSeed, int);
+    itkGetConstMacro(NumberOfSlicesToSkipBeforeSearchingSeed, int);
+    GGO_DefineOption(skipslices, SetNumberOfSlicesToSkipBeforeSearchingSeed, int);
+    
     itkSetMacro(LowerThreshold, InputImagePixelType);
     itkGetConstMacro(LowerThreshold, InputImagePixelType);
     itkSetMacro(UseLowerThreshold, bool);
@@ -193,15 +179,15 @@ public:
     itkGetConstMacro(LabelizeParameters3, LabelParamType*);
     GGO_DefineOption_LabelParam(3, SetLabelizeParameters3, LabelParamType);
 
-    // Step 5 options LungSeparation
-    //     itkSetMacro(FinalOpenClose, bool);
-    //     itkGetConstMacro(FinalOpenClose, bool);
-    //     itkBooleanMacro(FinalOpenClose);
+    // Step 5 final openclose
+    itkSetMacro(FinalOpenClose, bool);
+    itkGetConstMacro(FinalOpenClose, bool);
+    itkBooleanMacro(FinalOpenClose);
+    GGO_DefineOption_Flag(openclose, SetFinalOpenClose);
 
-    // Bronchial bifurcations
-    itkSetMacro(FindBronchialBifurcations, bool);
-    itkGetConstMacro(FindBronchialBifurcations, bool);
-    itkBooleanMacro(FindBronchialBifurcations);
+    itkSetMacro(FinalOpenCloseRadius, int);
+    itkGetConstMacro(FinalOpenCloseRadius, int);
+    GGO_DefineOption(opencloseRadius, SetFinalOpenCloseRadius, int);
 
   protected:
     ExtractLungFilter();
@@ -236,6 +222,7 @@ public:
     InputImagePixelType m_ThresholdStepSizeForTrachea;
     double m_MultiplierForTrachea;
     std::vector<InternalIndexType> m_Seeds;
+    int m_NumberOfSlicesToSkipBeforeSearchingSeed;
 
     // Step 3
     int m_NumberOfHistogramBins;
@@ -246,19 +233,19 @@ public:
     LabelParamType* m_LabelizeParameters3;
 
     // Step 5
-    //     bool m_FinalOpenClose;
-    
-    bool m_FindBronchialBifurcations;
-    
+    bool m_FinalOpenClose;    
+    int m_FinalOpenCloseRadius;
+
+    // Main functions
     virtual void GenerateOutputInformation();
     virtual void GenerateData();
+    
+    // Functions for trachea extraction
+    bool SearchForTracheaSeed(int skip);
+    void SearchForTrachea();
+    void TracheaRegionGrowing();
+    double ComputeTracheaVolume();
 
-    typedef Bifurcation<MaskImageIndexType,MaskImagePixelType> BifurcationType;
-    void TrackFromThisIndex(std::vector<BifurcationType> & listOfBifurcations, 
-                            MaskImagePointer skeleton, 
-                            MaskImageIndexType index,
-                            MaskImagePixelType label);
-        
   private:
     ExtractLungFilter(const Self&); //purposely not implemented
     void operator=(const Self&); //purposely not implemented