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