17 #ifndef __itkSimpleFuzzyConnectednessScalarImageFilter_txx
18 #define __itkSimpleFuzzyConnectednessScalarImageFilter_txx
21 #include "vnl/vnl_math.h"
23 #include "itkNumericTraits.h"
27 template <
class TInputImage,
class TOutputImage>
34 m_Diff_Variance = 0.0;
37 template <
class TInputImage,
class TOutputImage>
44 template <
class TInputImage,
class TOutputImage>
48 (
const double inmean,
const double invar,
const double indifmean,
49 const double indifvar,
const double inweight)
53 m_Diff_Mean = indifmean;
54 m_Diff_Variance = indifvar;
66 this->SetWeight(inweight);
70 template <
class TInputImage,
class TOutputImage>
75 double tmp1 = 0.5 * (f1 + f2) - m_Mean;
76 if(this->GetWeight() == 1)
78 return( (NumericTraits<unsigned short>::max())*
79 (vcl_exp(-0.5 * tmp1 * tmp1 / m_Variance)));
83 double tmp2 = vcl_fabs(static_cast<double>(f1) - static_cast<double>(f2)) - m_Diff_Mean;
84 return( (NumericTraits<unsigned short>::max()) *
85 (this->GetWeight() * vcl_exp(-0.5 * tmp1 * tmp1 / m_Variance) +
86 (1 - this->GetWeight()) * vcl_exp(-0.5 * tmp2 * tmp2 / m_Diff_Variance)));
90 template <
class TInputImage,
class TOutputImage>
95 Superclass::PrintSelf(os, indent);
96 os << indent <<
"Mean = " << m_Mean << std::endl;
97 os << indent <<
"Diff_Mean = " << m_Diff_Mean << std::endl;
98 os << indent <<
"Variance = " << m_Variance << std::endl;
99 os << indent <<
"Diff_Variance = " << m_Diff_Variance << std::endl;