18 #ifndef __itkCompositeValleyFunction_h
19 #define __itkCompositeValleyFunction_h
76 TargetClass(
double mean,
double sigma)
83 void SetMean(
double mean) { m_Mean = mean; }
84 double GetMean() {
return m_Mean; }
88 void SetSigma(
double sigma) { m_Sigma = sigma; }
89 double GetSigma() {
return m_Sigma; }
96 class ITK_EXPORT CompositeValleyFunction:
public CacheableScalarFunction
101 typedef CacheableScalarFunction Superclass;
104 typedef Superclass::MeasureType MeasureType;
105 typedef Superclass::MeasureArrayType MeasureArrayType;
108 CompositeValleyFunction(
const MeasureArrayType & classMeans,
109 const MeasureArrayType & classSigmas);
112 virtual ~CompositeValleyFunction() {}
115 double GetUpperBound() {
return m_UpperBound; }
118 double GetLowerBound() {
return m_LowerBound; }
122 MeasureType operator()(MeasureType x)
124 if ( x > m_UpperBound || x < m_LowerBound )
129 if ( !this->IsCacheAvailable() )
131 return this->Evaluate(x);
135 return GetCachedValue(x);
140 inline MeasureType Evaluate(MeasureType x)
144 for (
unsigned int k = 0; k < m_Targets.size(); k++ )
146 res *= valley( ( x - m_Targets[k].GetMean() )
147 / m_Targets[k].GetSigma() );
154 inline MeasureType valley(MeasureType d)
156 return 1 - 1 / ( 1 + d * d / 3 );
160 void AddNewClass(
double mean,
double sigma)
162 TargetClass aClass(mean, sigma);
164 m_Targets.push_back(aClass);
172 std::vector< TargetClass > m_Targets;