Orfeo Toolbox  3.16
itkWatershedBoundaryResolver.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkWatershedBoundaryResolver.txx,v $
5  Language: C++
6  Date: $Date: 2009-01-27 19:30:17 $
7  Version: $Revision: 1.9 $
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 __itkWatershedBoundaryResolver_txx
18 #define __itkWatershedBoundaryResolver_txx
20 
21 #include "itkImageRegionIterator.h"
22 
23 namespace itk
24 {
25 namespace watershed
26 {
27 
28 template <class TPixelType, unsigned int TDimension>
31 {
32  //
33  // NOTE: This method does not yet support arbitrary connectivity
34  // across the boundary. It does support arbitrary dimensions.
35  // See itkWatershedSegmenter for details. City-block style connectivity
36  // is assumed (ie 4-, 6- for 2d, 3d). jc 11/14/01
37  //
38  typedef typename BoundaryType::face_t FaceType;
39  typename BoundaryType::IndexType idxA;
40  typename BoundaryType::IndexType idxB;
41 
42  EquivalencyTableType::Pointer equivTable = this->GetEquivalencyTable();
43 
44  typename BoundaryType::Pointer boundaryA = this->GetBoundaryA();
45  typename BoundaryType::Pointer boundaryB = this->GetBoundaryB();
46 
47  idxA.first = this->GetFace();
48  idxB.first = this->GetFace();
49  idxA.second = 1; // HIGH face matches
50  idxB.second = 0; // the LOW face.
51 
52  // Initialize current minLabel
53  // Initialize the current boundsMin
54  // For each flat region frA in boundaryA:
55  // For each offset offA in frA:
56  // Lookup the flat region in boundaryB into which it flows: frB
57  // If frB.bounds_min < boundsMin then boundsMin =frB.bounds_min
58  // and minLabel = frB.minLabel
59  // Create equivalencies for all offA.labels, the frA label, and
60  // the minLabel
61 
62  //
63  // For each boundary pixel in boundaryA then in boundary B:
64  // 1) Does A flow to B? or B flow to A?
65  // 2) If (1) then create equivalency to the label
66  // into which this pixel flows.
67  //
68  // This constructs equivalencies between both flat regions and
69  // non-flat regions.
70  //
71  ImageRegionIterator<FaceType> itA(boundaryA->GetFace(idxA),
72  boundaryA->GetFace(idxA)->GetRequestedRegion());
73 
74  ImageRegionIterator<FaceType> itB(boundaryB->GetFace(idxB),
75  boundaryB->GetFace(idxB)->GetRequestedRegion());
76 
77  for (itA = itA.Begin(), itB = itB.Begin(); !itA.IsAtEnd(); ++itA, ++itB )
78  {
79  if ( itA.Get().flow != SegmenterType::NULL_FLOW )
80  {
81  equivTable->Add(itA.Get().label, itB.Get().label);
82  }
83  if ( itB.Get().flow != SegmenterType::NULL_FLOW )
84  {
85  equivTable->Add(itA.Get().label, itB.Get().label);
86  }
87  }
88 
89  equivTable->Flatten();
90 }
91 
92 // ------------------------------------------------------------
93 // --------------------PIPELINE METHODS------------------------
94 // ------------------------------------------------------------
95 template <class TPixelType, unsigned int TDimension>
98 {
99 }
100 
101 template<class TPixelType, unsigned int TDimension>
104 ::MakeOutput(unsigned int )
105 {
106  return static_cast<DataObject*>(EquivalencyTable::New().GetPointer());
107 }
108 
109 template<class TPixelType, unsigned int TDimension>
110 void
112 ::PrintSelf(std::ostream& os, Indent indent) const
113 {
114  Superclass::PrintSelf(os,indent);
115 
116  os << indent << "Face = " << m_Face << std::endl;
117 }
118 
119 
120 } // end namespace watershed
121 } // end namespace itk
122 
123 #endif

Generated at Sun Feb 3 2013 00:14:38 for Orfeo Toolbox with doxygen 1.8.1.1