ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkCompositeValleyFunction.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 itkCompositeValleyFunction_h
19#define itkCompositeValleyFunction_h
20
22#include "ITKBiasCorrectionExport.h"
23#include <vector>
24
25namespace itk
26{
68{
69public:
71 TargetClass(double mean, double sigma)
72 : m_Mean(mean)
73 , m_Sigma(sigma)
74 {}
75
78 void
79 SetMean(double mean)
80 {
81 m_Mean = mean;
82 }
83 [[nodiscard]] double
84 GetMean() const
85 {
86 return m_Mean;
87 }
88
91 void
92 SetSigma(double sigma)
93 {
94 m_Sigma = sigma;
95 }
96 [[nodiscard]] double
97 GetSigma() const
98 {
99 return m_Sigma;
100 }
101
102private:
103 double m_Mean;
104 double m_Sigma;
105}; // end of class
106
107class ITKBiasCorrection_EXPORT CompositeValleyFunction : public CacheableScalarFunction
108{
109public:
112
116
118 CompositeValleyFunction(const MeasureArrayType & classMeans, const MeasureArrayType & classSigmas);
119
122
124 [[nodiscard]] double
126 {
127 return m_UpperBound;
128 }
129
131 [[nodiscard]] double
133 {
134 return m_LowerBound;
135 }
136
139 MeasureType
141 {
142 if (x > m_UpperBound || x < m_LowerBound)
143 {
144 return 1;
145 }
146
147 if (!this->IsCacheAvailable())
148 {
149 return this->Evaluate(x);
150 }
151
152 return GetCachedValue(x);
153 }
154
156 MeasureType
158
160 inline MeasureType
162 {
163 return 1 - 1 / (1 + d * d / 3);
164 }
165
166protected:
167 void
168 AddNewClass(double mean, double sigma)
169 {
170 const TargetClass aClass(mean, sigma);
171
172 m_Targets.push_back(aClass);
173 }
174
176 void
178
179private:
181 std::vector<TargetClass> m_Targets{};
182
185 double m_UpperBound{};
186
189 double m_LowerBound{};
190}; // end of class
191} // end of namespace itk
192#endif
MeasureType GetCachedValue(MeasureType x)
CompositeValleyFunction(const MeasureArrayType &classMeans, const MeasureArrayType &classSigmas)
MeasureType operator()(MeasureType x)
MeasureType Evaluate(MeasureType x) override
void AddNewClass(double mean, double sigma)
Superclass::MeasureArrayType MeasureArrayType
void SetSigma(double sigma)
TargetClass(double mean, double sigma)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....