ITK  6.0.0
Insight Toolkit
itkKLMSegmentationBorder.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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 itkKLMSegmentationBorder_h
19#define itkKLMSegmentationBorder_h
20
23#include "itkMacro.h"
24#include "ITKKLMRegionGrowingExport.h"
25#include "itkMath.h"
26#include "vnl/vnl_vector.h"
27
28namespace itk
29{
42template <typename TBorder>
44{
45public:
53 bool
55 {
56 if (Math::ExactlyEquals(m_Pointer->GetLambda(), rhs.m_Pointer->GetLambda()))
57 {
58 if (m_Pointer->GetLambda() < 0)
59 {
60 return (m_Pointer > rhs.m_Pointer);
61 }
62 else
63 {
64 // The purpose of this comparison is to not let any one region
65 // get more borders than another region. In the degenerate
66 // case of an image where the Lambdas are always equal to some
67 // constant C, allowing a single region to be repeatedly
68 // merged so that it gains many borders will result in
69 // pathologically slow behavior.
70 double v1 = std::max(static_cast<double>(m_Pointer->GetRegion1()->GetRegionBorderSize()),
71 static_cast<double>(m_Pointer->GetRegion2()->GetRegionBorderSize()));
74 double v2 = std::max(static_cast<double>(rhs.m_Pointer->GetRegion1()->GetRegionBorderSize()),
75 static_cast<double>(rhs.m_Pointer->GetRegion2()->GetRegionBorderSize()));
76
77 return (v1 > v2);
78 }
79 }
80 return (m_Pointer->GetLambda() > rhs.m_Pointer->GetLambda());
81 }
82
83 bool
85 {
86 if (m_Pointer->GetLambda() == rhs->m_Pointer->GetLambda())
87 {
88 if (m_Pointer->GetLambda() < 0)
89 {
90 return (m_Pointer > rhs->m_Pointer);
91 }
92 else
93 {
94 // The purpose of this comparison is to not let any one region
95 // get more borders than another region. In the degenerate
96 // case of an image where the Lambdas are always equal to some
97 // constant C, allowing a single region to be repeatedly
98 // merged so that it gains many borders will result in
99 // pathologically slow behavior.
100 double v1 = std::max(static_cast<double>(m_Pointer->GetRegion1()->GetRegionBorderSize()),
101 static_cast<double>(m_Pointer->GetRegion2()->GetRegionBorderSize()));
102
103 double v2 = std::max(static_cast<double>(rhs->m_Pointer->GetRegion1()->GetRegionBorderSize()),
104 static_cast<double>(rhs->m_Pointer->GetRegion2()->GetRegionBorderSize()));
105
106 return (v1 > v2);
107 }
108 }
109 return (m_Pointer->GetLambda() > rhs->m_Pointer->GetLambda());
110 }
111
112 TBorder * m_Pointer;
113};
114
135// Forward reference because of circular dependencies
136class ITK_FORWARD_EXPORT KLMSegmentationRegion;
137
138class ITKKLMRegionGrowing_EXPORT KLMSegmentationBorder : public SegmentationBorder
139{
140public:
141 ITK_DISALLOW_COPY_AND_MOVE(KLMSegmentationBorder);
142
148
150 itkNewMacro(Self);
151
153 itkOverrideGetNameOfClassMacro(KLMSegmentationBorder);
154
156 void
158
162
164 void
166
170
173 itkSetMacro(Lambda, double);
174 itkGetConstReferenceMacro(Lambda, double);
178 void
180
182 void
184
185protected:
188
191
193 void
194 PrintSelf(std::ostream & os, Indent indent) const override;
195
196private:
197 double m_Lambda{};
200};
201} // end namespace itk
202
203#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Object maintaining a reference to a list of borders associated with a region.
bool operator>(const KLMDynamicBorderArray< TBorder > *rhs) const
bool operator>(const KLMDynamicBorderArray< TBorder > &rhs) const
Base class for KLMSegmentationBorder object.
void SetRegion2(KLMSegmentationRegion *Region2)
KLMSegmentationRegion * GetRegion2()
KLMSegmentationRegion * GetRegion1()
void SetRegion1(KLMSegmentationRegion *Region1)
void PrintSelf(std::ostream &os, Indent indent) const override
Base class for KLMSegmentationRegion object.
Light weight base class for most itk classes.
Base class for SegmentationBorder object.
bool ExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Return the result of an exact comparison between two scalar values of potentially different types.
Definition: itkMath.h:726
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
class ITK_FORWARD_EXPORT KLMSegmentationBorder