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{
67class TargetClass
68{
69public:
70
72 TargetClass(double mean, double sigma)
73 {
74 m_Mean = mean;
75 m_Sigma = sigma;
76 }
77
79 void
80 SetMean(double mean)
81 {
82 m_Mean = mean;
83 }
84 double
85 GetMean() const
86 {
87 return m_Mean;
88 }
90
92 void
93 SetSigma(double sigma)
94 {
95 m_Sigma = sigma;
96 }
97 double
98 GetSigma() const
99 {
100 return m_Sigma;
101 }
103
104private:
105 double m_Mean;
106 double m_Sigma;
107}; // end of class
108
109class ITKBiasCorrection_EXPORT CompositeValleyFunction : public CacheableScalarFunction
110{
111public:
113 using Superclass = CacheableScalarFunction;
114
116 using MeasureType = Superclass::MeasureType;
117 using MeasureArrayType = Superclass::MeasureArrayType;
118
120 CompositeValleyFunction(const MeasureArrayType & classMeans, const MeasureArrayType & classSigmas);
121
123 ~CompositeValleyFunction() override;
124
126 double
127 GetUpperBound() const
128 {
129 return m_UpperBound;
130 }
131
133 double
134 GetLowerBound() const
135 {
136 return m_LowerBound;
137 }
138
141 MeasureType
142 operator()(MeasureType x)
143 {
144 if (x > m_UpperBound || x < m_LowerBound)
145 {
146 return 1;
147 }
148
149 if (!this->IsCacheAvailable())
150 {
151 return this->Evaluate(x);
152 }
153
154 return GetCachedValue(x);
155 }
156
158 MeasureType
159 Evaluate(MeasureType x) override;
160
162 inline MeasureType
163 valley(MeasureType d)
164 {
165 return 1 - 1 / (1 + d * d / 3);
166 }
167
168protected:
169 void
170 AddNewClass(double mean, double sigma)
171 {
172 const TargetClass aClass(mean, sigma);
173
174 m_Targets.push_back(aClass);
175 }
176
178 void
179 Initialize();
180
181private:
183 std::vector<TargetClass> m_Targets{};
184
187 double m_UpperBound{};
188
BinaryGeneratorImageFilter< TInputImage1, TInputImage2, TOutputImage > Superclass
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....