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; }
97 class ITK_EXPORT CompositeValleyFunction:
public CacheableScalarFunction
102 typedef CacheableScalarFunction Superclass;
105 typedef Superclass::MeasureType MeasureType;
106 typedef Superclass::MeasureArrayType MeasureArrayType;
109 CompositeValleyFunction(
const MeasureArrayType & classMeans,
110 const MeasureArrayType & classSigmas);
113 virtual ~CompositeValleyFunction() {}
116 double GetUpperBound() {
return m_UpperBound; }
119 double GetLowerBound() {
return m_LowerBound; }
123 MeasureType operator()(MeasureType x)
125 if ( x > m_UpperBound || x < m_LowerBound )
130 if ( !this->IsCacheAvailable() )
132 return this->Evaluate(x);
136 return GetCachedValue(x);
141 inline MeasureType Evaluate(MeasureType x)
145 for (
unsigned int k = 0; k < m_Targets.size(); k++ )
147 res *= valley( ( x - m_Targets[k].GetMean() )
148 / m_Targets[k].GetSigma() );
155 inline MeasureType valley(MeasureType d)
157 return 1 - 1 / ( 1 + d * d / 3 );
161 void AddNewClass(
double mean,
double sigma)
163 TargetClass aClass(mean, sigma);
165 m_Targets.push_back(aClass);
173 std::vector< TargetClass > m_Targets;