Orfeo Toolbox  4.2
itkWatershedSegmenter.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 __itkWatershedSegmenter_h
19 #define __itkWatershedSegmenter_h
20 
21 
22 #include "itkWatershedBoundary.h"
24 #include "itkEquivalencyTable.h"
25 
26 namespace itk
27 {
28 namespace watershed
29 {
87 template< typename TInputImage >
88 class Segmenter:
89  public ProcessObject
90 {
91 public:
93  typedef Segmenter Self;
94 
96  typedef TInputImage InputImageType;
97  itkStaticConstMacro(ImageDimension, unsigned int,
98  TInputImage::ImageDimension);
99 
102  typedef typename InputImageType::RegionType ImageRegionType;
103  typedef typename InputImageType::PixelType InputPixelType;
110 
116  itkNewMacro(Self);
117  itkTypeMacro(WatershedSegmenter, ProcessObject);
118 
120  typedef typename InputImageType::Pointer InputImageTypePointer;
124 
126  itkStaticConstMacro(NULL_LABEL, unsigned long, 0);
127 
129  itkStaticConstMacro(NULL_FLOW, unsigned long, -1);
130 
133  {
134  return itkDynamicCastInDebugMode< InputImageType * >
135  ( this->ProcessObject::GetInput(0) );
136  }
137 
139  { this->ProcessObject::SetNthInput(0, img); }
140 
144  {
145  return itkDynamicCastInDebugMode< OutputImageType * >
146  ( this->ProcessObject::GetOutput(0) );
147  }
148 
150  { this->ProcessObject::SetNthOutput(0, img); }
151 
155  {
156  return itkDynamicCastInDebugMode< SegmentTableType * >
157  ( this->ProcessObject::GetOutput(1) );
158  }
159 
161  { this->ProcessObject::SetNthOutput(1, s); }
162 
166  {
167  return itkDynamicCastInDebugMode< BoundaryType * >
168  ( this->ProcessObject::GetOutput(2) );
169  }
170 
172  { this->ProcessObject::SetNthOutput(2, b); }
173 
175  virtual void GenerateData() ITK_OVERRIDE;
176 
184  {
185  if ( reg == m_LargestPossibleRegion ) { return; }
187  this->Modified();
188  }
189 
191  { return m_LargestPossibleRegion; }
192 
198 
203 
206  itkSetMacro(CurrentLabel, IdentifierType);
207  itkGetConstMacro(CurrentLabel, IdentifierType);
208 
219  itkSetClampMacro(Threshold, double, 0.0, 1.0);
220  itkGetConstMacro(Threshold, double);
221 
225  itkSetMacro(DoBoundaryAnalysis, bool);
226  itkGetConstMacro(DoBoundaryAnalysis, bool);
227 
232  itkGetConstMacro(SortEdgeLists, bool);
233  itkSetMacro(SortEdgeLists, bool);
234 
235 protected:
238  struct flat_region_t {
241  // InputPixelType bounds_max; // <-- may not be necc.
245  };
246 
248  typedef itksys::hash_map< IdentifierType, flat_region_t, itksys::hash< IdentifierType > >
250 
251  struct connectivity_t {
252  unsigned int size;
253  unsigned int *index;
255  };
256 
261  typedef itksys::hash_map< IdentifierType, InputPixelType, itksys::hash< IdentifierType >
263 
264  typedef itksys::hash_map< IdentifierType, edge_table_t, itksys::hash< IdentifierType >
266 
267  Segmenter();
268  Segmenter(const Self &) {}
269  virtual ~Segmenter();
270  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
271 
272  void operator=(const Self &) {}
273 
276  virtual void GenerateConnectivity();
277 
281  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
282 
283  virtual void GenerateOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
284 
285  virtual void UpdateOutputInformation() ITK_OVERRIDE;
286 
289  void InitializeBoundary();
290 
297 
301  void BuildRetainingWall(InputImageTypePointer,
302  ImageRegionType, InputPixelType);
303 
306  void LabelMinima(InputImageTypePointer,
307  ImageRegionType, flat_region_table_t &,
308  InputPixelType);
309 
313  void GradientDescent(InputImageTypePointer, ImageRegionType);
314 
317  void DescendFlatRegions(flat_region_table_t &, ImageRegionType);
318 
321  void UpdateSegmentTable(InputImageTypePointer, ImageRegionType);
322 
326  void CollectBoundaryInformation(flat_region_table_t &);
327 
333  static void Threshold(InputImageTypePointer destination,
334  InputImageTypePointer source,
335  const ImageRegionType source_region,
336  const ImageRegionType destination_region,
337  InputPixelType threshold);
338 
340  static void MinMax(InputImageTypePointer img,
341  ImageRegionType region,
342  InputPixelType & min,
343  InputPixelType & max);
344 
346  static void MergeFlatRegions(flat_region_table_t &, EquivalencyTable::Pointer);
347 
349  static void SetInputImageValues(InputImageTypePointer img,
350  const ImageRegionType region,
351  InputPixelType value);
352 
354  const ImageRegionType region,
355  IdentifierType value);
356 
358  // bool CheckLabeledBoundaries();
359 
362  connectivity_t m_Connectivity;
363 
364 private:
366  // void PrintFlatRegions(flat_region_table_t &t);
367 
371  ImageRegionType m_LargestPossibleRegion;
372 
375  double m_Threshold;
378 };
379 } // end namespace watershed
380 } // end namespace itk
381 
382 #ifndef ITK_MANUAL_INSTANTIATION
383 #include "itkWatershedSegmenter.hxx"
384 #endif
385 
386 #endif

Generated at Sat Aug 30 2014 15:52:23 for Orfeo Toolbox with doxygen 1.8.3.1