]> Creatis software - clitk.git/blob - itk/clitkLocallyAdaptiveThresholdConnectedImageFilter.h
Cosmetic
[clitk.git] / itk / clitkLocallyAdaptiveThresholdConnectedImageFilter.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 #ifndef __clitkLocallyAdaptiveThresholdConnectedImageFilter_h
19 #define __clitkLocallyAdaptiveThresholdConnectedImageFilter_h
20 #include "itkImage.h"
21 #include "itkImageToImageFilter.h"
22
23 namespace clitk {
24
25 /** \class LocallyAdaptiveThresholdConnectedImageFilter
26  * \brief Label pixels that are connected to a seed and lie within a neighborhood
27  * 
28  * LocallyAdaptiveThresholdConnectedImageFilter labels pixels with ReplaceValue that
29  * are connected to an initial Seed AND whose neighbors all lie within a
30  * Lower and Upper threshold range.
31  *
32  * \ingroup RegionGrowingSegmentation 
33  */
34 template <class TInputImage, class TOutputImage>
35 class ITK_EXPORT LocallyAdaptiveThresholdConnectedImageFilter:
36     public itk::ImageToImageFilter<TInputImage,TOutputImage>
37 {
38 public:
39   /** Standard class typedefs. */
40   typedef LocallyAdaptiveThresholdConnectedImageFilter             Self;
41   typedef itk::ImageToImageFilter<TInputImage,TOutputImage> Superclass;
42   typedef itk::SmartPointer<Self>                           Pointer;
43   typedef itk::SmartPointer<const Self>                     ConstPointer;
44
45   /** Method for creation through the object factory. */
46   itkNewMacro(Self);
47
48   /** Run-time type information (and related methods).  */
49   itkTypeMacro(LocallyAdaptiveThresholdConnectedImageFilter,
50                ImageToImageFilter);
51
52   typedef TInputImage                         InputImageType;
53   typedef typename InputImageType::Pointer    InputImagePointer;
54   typedef typename InputImageType::RegionType InputImageRegionType; 
55   typedef typename InputImageType::PixelType  InputImagePixelType; 
56   typedef typename InputImageType::IndexType  IndexType;
57   typedef typename InputImageType::SizeType   InputImageSizeType;
58   
59   typedef TOutputImage                         OutputImageType;
60   typedef typename OutputImageType::Pointer    OutputImagePointer;
61   typedef typename OutputImageType::RegionType OutputImageRegionType; 
62   typedef typename OutputImageType::PixelType  OutputImagePixelType; 
63   
64   void PrintSelf ( std::ostream& os, itk::Indent indent ) const ITK_OVERRIDE;
65
66   /** Clear the seeds */
67   void ClearSeeds();
68
69   /** Set seed point. */
70   void SetSeed(const IndexType & seed);
71
72   /** Add a seed point */
73   void AddSeed ( const IndexType & seed );
74
75   // Set/Get the lower threshold. The default is 0.
76   itkSetMacro(Lower, InputImagePixelType);
77   itkGetConstMacro(Lower, InputImagePixelType);
78
79   // Set/Get the upper threshold. The default is the largest possible value for the InputPixelType.
80   itkSetMacro(Upper, InputImagePixelType);
81   itkGetConstMacro(Upper, InputImagePixelType);
82   
83   /** Set/Get value to replace thresholded pixels. Pixels that lie *
84    *  within Lower and Upper (inclusive) will be replaced with this
85    *  value. The default is 1. */
86   itkSetMacro(ReplaceValue, OutputImagePixelType);
87   itkGetConstMacro(ReplaceValue, OutputImagePixelType);
88
89   /** Set the radius of the neighborhood used for a mask. */
90   itkSetMacro(Radius, InputImageSizeType);
91
92   /** Get the radius of the neighborhood used to compute the median */
93   itkGetConstReferenceMacro(Radius, InputImageSizeType);
94
95   /** ImageDimension constants */
96   itkStaticConstMacro(InputImageDimension, unsigned int,
97                       TInputImage::ImageDimension);
98   itkStaticConstMacro(OutputImageDimension, unsigned int,
99                       TOutputImage::ImageDimension);
100
101 #ifdef ITK_USE_CONCEPT_CHECKING
102   /** Begin concept checking */
103   itkConceptMacro(InputEqualityComparableCheck,
104                   (itk::Concept::EqualityComparable<InputImagePixelType>));
105   itkConceptMacro(OutputEqualityComparableCheck,
106                   (itk::Concept::EqualityComparable<OutputImagePixelType>));
107   itkConceptMacro(SameDimensionCheck,
108                   (itk::Concept::SameDimension<InputImageDimension, OutputImageDimension>));
109   itkConceptMacro(InputOStreamWritableCheck,
110                   (itk::Concept::OStreamWritable<InputImagePixelType>));
111   itkConceptMacro(OutputOStreamWritableCheck,
112                   (itk::Concept::OStreamWritable<OutputImagePixelType>));
113   /** End concept checking */
114 #endif
115
116   // JV
117   itkBooleanMacro(LowerBorderIsGiven);
118   itkSetMacro( LowerBorderIsGiven, bool);
119   itkGetConstReferenceMacro( LowerBorderIsGiven, bool);
120   itkBooleanMacro(UpperBorderIsGiven);
121   itkSetMacro( UpperBorderIsGiven, bool);
122   itkGetConstReferenceMacro( UpperBorderIsGiven, bool);
123   itkSetMacro( Multiplier, double);
124   itkGetConstMacro( Multiplier, double);
125   itkBooleanMacro(MaximumSDIsGiven);
126   itkSetMacro( MaximumSDIsGiven, bool);
127   itkGetConstReferenceMacro( MaximumSDIsGiven, bool);
128   itkSetMacro( MaximumSD, double);
129   itkGetConstMacro( MaximumSD, double);
130
131 protected:
132   LocallyAdaptiveThresholdConnectedImageFilter();
133   ~LocallyAdaptiveThresholdConnectedImageFilter(){};
134   std::vector<IndexType> m_Seeds;
135   InputImagePixelType    m_Lower;
136   InputImagePixelType    m_Upper;
137   OutputImagePixelType   m_ReplaceValue;
138   InputImageSizeType     m_Radius;
139
140   // JV 
141   bool m_LowerBorderIsGiven;
142   bool m_UpperBorderIsGiven;
143   bool m_MaximumSDIsGiven;
144   double m_Multiplier;
145   double m_MaximumSD;
146
147   // Override since the filter needs all the data for the algorithm
148   void GenerateInputRequestedRegion() ITK_OVERRIDE;
149
150   // Override since the filter produces the entire dataset
151   void EnlargeOutputRequestedRegion(itk::DataObject *output) ITK_OVERRIDE;
152   void GenerateData() ITK_OVERRIDE;
153   
154 private:
155   LocallyAdaptiveThresholdConnectedImageFilter(const Self&); //purposely not implemented
156   void operator=(const Self&); //purposely not implemented
157
158 };
159
160 } // end namespace clitk
161
162 #ifndef ITK_MANUAL_INSTANTIATION
163 #include "clitkLocallyAdaptiveThresholdConnectedImageFilter.txx"
164 #endif
165
166 #endif