Orfeo Toolbox  3.16
itkWatershedSegmenter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: itkWatershedSegmenter.h
5  Language: C++
6  Date: $Date$
7  Version: $Revision$
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkWatershedSegmenter_h
18 #define __itkWatershedSegmenter_h
19 
20 #if defined(_MSC_VER)
21 #pragma warning ( disable : 4786 )
22 #endif
23 
24 #include "itk_hash_map.h"
25 #include "itkWatershedBoundary.h"
27 #include "itkEquivalencyTable.h"
28 #include "itkImage.h"
29 
30 namespace itk
31 {
32 namespace watershed
33 {
89 template <class TInputImage>
91  : public ProcessObject
92 {
93 public:
95  typedef Segmenter Self;
96 
98  typedef TInputImage InputImageType;
99  itkStaticConstMacro(ImageDimension, unsigned int,
100  TInputImage::ImageDimension);
101 
104  typedef typename InputImageType::RegionType ImageRegionType;
105  typedef typename InputImageType::PixelType InputPixelType;
112 
118  itkNewMacro(Self);
119  itkTypeMacro(WatershedSegmenter, ProcessObject);
120 
122  typedef typename InputImageType::Pointer InputImageTypePointer;
126 
128  static unsigned long NULL_LABEL;
129 
131  static short NULL_FLOW;
132 
134  InputImageType * GetInputImage(void)
135  {
136  return static_cast<InputImageType *>
137  (this->ProcessObject::GetInput(0));
138  }
139  void SetInputImage(InputImageType *img)
140  { this->ProcessObject::SetNthInput(0, img); }
141 
144  OutputImageType * GetOutputImage(void)
145  {
146  return static_cast<OutputImageType *>
147  (this->ProcessObject::GetOutput(0));
148  }
149  void SetOutputImage(OutputImageType *img)
150  { this->ProcessObject::SetNthOutput(0, img); }
151 
154  SegmentTableType * GetSegmentTable(void)
155  {
156  return static_cast<SegmentTableType *>
157  (this->ProcessObject::GetOutput(1));
158  }
159  void SetSegmentTable(SegmentTableType *s)
160  { this->ProcessObject::SetNthOutput(1, s); }
161 
164  BoundaryType * GetBoundary(void)
165  {
166  return static_cast<BoundaryType *>
167  (this->ProcessObject::GetOutput(2));
168  }
169  void SetBoundary(BoundaryType *b)
170  { this->ProcessObject::SetNthOutput(2,b); }
171 
173  void GenerateData();
174 
181  void SetLargestPossibleRegion(ImageRegionType reg)
182  {
183  if (reg == m_LargestPossibleRegion) return;
184  m_LargestPossibleRegion = reg;
185  this->Modified();
186  }
187  ImageRegionType GetLargestPossibleRegion() const
188  { return m_LargestPossibleRegion; }
189 
192  static void RelabelImage(OutputImageTypePointer,
193  ImageRegionType,
195 
197  virtual DataObjectPointer MakeOutput(unsigned int idx);
198 
201  itkSetMacro(CurrentLabel, unsigned long);
202  itkGetConstMacro(CurrentLabel, unsigned long);
203 
214  itkSetClampMacro(Threshold, double, 0.0, 1.0);
215  itkGetConstMacro(Threshold, double);
216 
220  itkSetMacro(DoBoundaryAnalysis, bool);
221  itkGetConstMacro(DoBoundaryAnalysis, bool);
222 
227  itkGetConstMacro(SortEdgeLists, bool);
228  itkSetMacro(SortEdgeLists, bool);
229 
230 protected:
234  {
235  unsigned long *min_label_ptr;
237  // InputPixelType bounds_max; // <-- may not be necc.
240  flat_region_t() : is_on_boundary(false) {}
241  };
242 
246 
248  {
249  unsigned int size;
250  unsigned int *index;
251  typename InputImageType::OffsetType *direction;
252  };
253 
260 
263 
264  Segmenter();
265  Segmenter(const Self&) {}
266  virtual ~Segmenter();
267  void PrintSelf(std::ostream& os, Indent indent) const;
268  void operator=(const Self&) {}
269 
272  virtual void GenerateConnectivity();
273 
277  void GenerateInputRequestedRegion();
278  void GenerateOutputRequestedRegion(DataObject *output);
279  void UpdateOutputInformation();
280 
283  void InitializeBoundary();
284 
288  void AnalyzeBoundaryFlow(InputImageTypePointer,
289  flat_region_table_t &,
290  InputPixelType);
291 
295  void BuildRetainingWall(InputImageTypePointer,
296  ImageRegionType, InputPixelType);
297 
300  void LabelMinima(InputImageTypePointer,
301  ImageRegionType, flat_region_table_t &,
302  InputPixelType);
303 
307  void GradientDescent(InputImageTypePointer, ImageRegionType);
308 
311  void DescendFlatRegions(flat_region_table_t &, ImageRegionType);
312 
315  void UpdateSegmentTable(InputImageTypePointer, ImageRegionType);
316 
320  void CollectBoundaryInformation(flat_region_table_t &);
321 
327  static void Threshold(InputImageTypePointer destination,
328  InputImageTypePointer source,
329  const ImageRegionType source_region,
330  const ImageRegionType destination_region,
331  InputPixelType threshold);
332 
334  static void MinMax(InputImageTypePointer img,
335  ImageRegionType region,
336  InputPixelType &min,
337  InputPixelType &max);
338 
340  static void MergeFlatRegions(flat_region_table_t &, EquivalencyTable::Pointer);
341 
343  static void SetInputImageValues(InputImageTypePointer img,
344  const ImageRegionType region,
345  InputPixelType value);
346 
347  static void SetOutputImageValues(OutputImageTypePointer img,
348  const ImageRegionType region,
349  unsigned long value);
350 
352  // bool CheckLabeledBoundaries();
353 
356  connectivity_t m_Connectivity;
357 
358 private:
360  // void PrintFlatRegions(flat_region_table_t &t);
361 
366 
369  double m_Threshold;
371  unsigned long m_CurrentLabel;
372 };
373 
374 }// end namespace watershed
375 }// end namespace itk
376 
377 #ifndef ITK_MANUAL_INSTANTIATION
378 #include "itkWatershedSegmenter.txx"
379 #endif
380 
381 #endif

Generated at Sun May 19 2013 00:15:13 for Orfeo Toolbox with doxygen 1.8.3.1