ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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{
41
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
63 // The purpose of this comparison is to not let any one region
64 // get more borders than another region. In the degenerate
65 // case of an image where the Lambdas are always equal to some
66 // constant C, allowing a single region to be repeatedly
67 // merged so that it gains many borders will result in
68 // pathologically slow behavior.
69 const double v1 = std::max(static_cast<double>(m_Pointer->GetRegion1()->GetRegionBorderSize()),
70 static_cast<double>(m_Pointer->GetRegion2()->GetRegionBorderSize()));
71
72 const double v2 = std::max(static_cast<double>(rhs.m_Pointer->GetRegion1()->GetRegionBorderSize()),
73 static_cast<double>(rhs.m_Pointer->GetRegion2()->GetRegionBorderSize()));
74
75 return (v1 > v2);
76 }
77 return (m_Pointer->GetLambda() > rhs.m_Pointer->GetLambda());
78 }
79
80 bool
82 {
83 if (m_Pointer->GetLambda() == rhs->m_Pointer->GetLambda())
84 {
85 if (m_Pointer->GetLambda() < 0)
86 {
87 return (m_Pointer > rhs->m_Pointer);
88 }
89
90 // The purpose of this comparison is to not let any one region
91 // get more borders than another region. In the degenerate
92 // case of an image where the Lambdas are always equal to some
93 // constant C, allowing a single region to be repeatedly
94 // merged so that it gains many borders will result in
95 // pathologically slow behavior.
96 double v1 = std::max(static_cast<double>(m_Pointer->GetRegion1()->GetRegionBorderSize()),
97 static_cast<double>(m_Pointer->GetRegion2()->GetRegionBorderSize()));
98
99 double v2 = std::max(static_cast<double>(rhs->m_Pointer->GetRegion1()->GetRegionBorderSize()),
100 static_cast<double>(rhs->m_Pointer->GetRegion2()->GetRegionBorderSize()));
101
102 return (v1 > v2);
103 }
104 return (m_Pointer->GetLambda() > rhs->m_Pointer->GetLambda());
105 }
106
107 TBorder * m_Pointer;
108};
109
129
130// Forward reference because of circular dependencies
131class ITK_FORWARD_EXPORT KLMSegmentationRegion;
132
133class ITKKLMRegionGrowing_EXPORT KLMSegmentationBorder : public SegmentationBorder
134{
135public:
136 ITK_DISALLOW_COPY_AND_MOVE(KLMSegmentationBorder);
137
143
145 itkNewMacro(Self);
146
148 itkOverrideGetNameOfClassMacro(KLMSegmentationBorder);
149
151 void
153
157
159 void
161
165
168 itkSetMacro(Lambda, double);
169 itkGetConstReferenceMacro(Lambda, double);
171
173 void
175
177 void
179
180protected:
183
186
188 void
189 PrintSelf(std::ostream & os, Indent indent) const override;
190
191private:
192 double m_Lambda{};
195};
196} // end namespace itk
197
198#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
void SetRegion2(KLMSegmentationRegion *Region2)
KLMSegmentationRegion * GetRegion2()
SmartPointer< const Self > ConstPointer
KLMSegmentationRegion * GetRegion1()
void SetRegion1(KLMSegmentationRegion *Region1)
void PrintSelf(std::ostream &os, Indent indent) const override
Base class for KLMSegmentationRegion object.
Implements transparent reference counting.
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:720
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....