]> Creatis software - clitk.git/blob - segmentation/clitkStructuresExtractionFilter.h
The lower and upper options can be tuned for all type of region growing algorithm
[clitk.git] / segmentation / clitkStructuresExtractionFilter.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://www.centreleonberard.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 CLITKSTRUCTURESEXTRACTIONFILTER_H
20 #define CLITKSTRUCTURESEXTRACTIONFILTER_H
21
22 // clitk
23 #include "clitkFilterWithAnatomicalFeatureDatabaseManagement.h"
24 #include "clitkFilterBase.h"
25 #include "clitkRelativePositionList.h"
26
27 namespace clitk {
28   
29   //--------------------------------------------------------------------
30   /*
31     - Convenient class to add some capabilities to a filter :
32     FilterBase, FilterWithAnatomicalFeatureDatabaseManagement and
33     RelativePositionList
34   */
35   //--------------------------------------------------------------------
36   template <class TImageType>
37   class StructuresExtractionFilter: 
38     public virtual FilterBase,
39     public clitk::FilterWithAnatomicalFeatureDatabaseManagement,
40     public itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> >     
41   {
42   public:
43     // Standard class typedefs
44     typedef StructuresExtractionFilter                                 Self;
45     typedef itk::ImageToImageFilter<TImageType, itk::Image<uchar, 3> > Superclass;
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(StructuresExtractionFilter, 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     typedef typename MaskSliceType::RegionType   MaskSliceRegionType; 
77     typedef typename MaskSliceType::SizeType     MaskSliceSizeType; 
78     typedef typename MaskSliceType::IndexType    MaskSliceIndexType; 
79     
80     /** ImageDimension constants */
81     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
82     FILTERBASE_INIT;
83    
84     itkGetConstMacro(BackgroundValue, MaskImagePixelType);
85     itkGetConstMacro(ForegroundValue, MaskImagePixelType);
86     itkSetMacro(BackgroundValue, MaskImagePixelType);
87     itkSetMacro(ForegroundValue, MaskImagePixelType);
88     
89     // RelativePositionList management 
90     void AddRelativePositionListFilename(std::string s);    
91     MaskImagePointer ApplyRelativePositionList(std::string name, MaskImageType * input, bool overlap=false);
92     
93    protected:
94     StructuresExtractionFilter();
95     virtual ~StructuresExtractionFilter() {}    
96     
97     virtual void GenerateData() {}
98     
99     MaskImagePixelType m_BackgroundValue;
100     MaskImagePixelType m_ForegroundValue;
101  
102     // RelativePositionList
103     std::vector<std::string> mListOfRelativePositionListFilename;
104     typedef clitk::RelativePositionList<MaskImageType> RelPosListType;
105     typedef typename RelPosListType::Pointer RelPosListPointer;
106     std::map<std::string, RelPosListPointer> mMapOfRelativePositionList;
107
108   private:
109     StructuresExtractionFilter(const Self&); //purposely not implemented
110     void operator=(const Self&); //purposely not implemented
111     
112   }; // end class
113   //--------------------------------------------------------------------
114
115 } // end namespace clitk
116 //--------------------------------------------------------------------
117
118 #include "clitkStructuresExtractionFilter.txx"
119
120 #endif // CLITKSTRUCTURESEXTRACTIONFILTER_H