ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkWatershedImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkWatershedImageFilter_h
19 #define __itkWatershedImageFilter_h
20 
21 
22 #include "itkImageToImageFilter.h"
24 #include "itkWatershedRelabeler.h"
26 
27 namespace itk
28 {
149 template< class TInputImage >
150 class ITK_EXPORT WatershedImageFilter:
151  public ImageToImageFilter< TInputImage, Image< IdentifierType,
152  TInputImage::ImageDimension > >
153 {
154 public:
157 
159  typedef TInputImage InputImageType;
160 
162  itkStaticConstMacro (ImageDimension, unsigned int,
163  TInputImage::ImageDimension);
164 
167 
169  typedef typename InputImageType::RegionType RegionType;
170  typedef typename InputImageType::SizeType SizeType;
171  typedef typename InputImageType::IndexType IndexType;
172 
175 
177  typedef typename InputImageType::PixelType ScalarType;
178 
181 
184 
186  itkNewMacro(Self);
187 
189  void GenerateData();
190 
193  using Superclass::SetInput;
194  void SetInput(const InputImageType *input)
195  {
196  // if the input is changed, we'll need to clear the cached tree
197  // when we execute
198  if ( input != this->GetInput(0) )
199  {
200  m_InputChanged = true;
201  }
203 
204  // processObject is not const-correct so a const_cast is needed here
205  this->ProcessObject::SetNthInput( 0, const_cast< InputImageType * >( input ) );
206  m_Segmenter->SetInputImage( const_cast< InputImageType * >( input ) );
207  }
208 
209  virtual void SetInput(unsigned int i, const TInputImage *image)
210  {
211  if ( i != 0 )
212  { itkExceptionMacro(<< "Filter has only one input."); }
213  else
214  { this->SetInput(image); }
215  }
216 
219  void SetThreshold(double);
220 
221  itkGetConstMacro(Threshold, double);
222 
225  void SetLevel(double);
226 
227  itkGetConstMacro(Level, double);
228 
231  GetBasicSegmentation()
232  {
233  m_Segmenter->Update();
234  return m_Segmenter->GetOutputImage();
235  }
237 
240  GetSegmentTree()
241  {
242  return m_TreeGenerator->GetOutputSegmentTree();
243  }
244 
245  // Override since the filter produces all of its output
246  void EnlargeOutputRequestedRegion(DataObject *data);
247 
248 #ifdef ITK_USE_CONCEPT_CHECKING
249 
250  itkConceptMacro( InputEqualityComparableCheck,
252  itkConceptMacro( InputAdditiveOperatorsCheck,
254  itkConceptMacro( DoubleInputMultiplyOperatorCheck,
256  itkConceptMacro( InputLessThanComparableCheck,
258 
260 #endif
261 
262 protected:
265  void PrintSelf(std::ostream & os, Indent indent) const;
266 
269  virtual void PrepareOutputs();
270 
271 private:
272  WatershedImageFilter(const Self &); //purposely not implemented
273  void operator=(const Self &); //purposely not implemented
274 
278  double m_Threshold;
279 
284  double m_Level;
285 
291 
293 
295 
296  unsigned long m_ObserverTag;
297 
301 
303 };
304 } // end namespace itk
305 
306 #ifndef ITK_MANUAL_INSTANTIATION
307 #include "itkWatershedImageFilter.hxx"
308 #endif
309 
310 #endif
311