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