Orfeo Toolbox  3.16
itkSimpleFuzzyConnectednessScalarImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkSimpleFuzzyConnectednessScalarImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2009-04-06 11:15:09 $
7  Version: $Revision: 1.5 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkSimpleFuzzyConnectednessScalarImageFilter_txx
18 #define __itkSimpleFuzzyConnectednessScalarImageFilter_txx
20 
21 #include "vnl/vnl_math.h"
23 #include "itkNumericTraits.h"
24 
25 namespace itk {
26 
27 template <class TInputImage, class TOutputImage>
30 {
31  m_Mean = 0.0;
32  m_Diff_Mean = 0.0;
33  m_Variance = 0.0;
34  m_Diff_Variance = 0.0;
35 }
36 
37 template <class TInputImage, class TOutputImage>
40 {
41 }
42 
43 
44 template <class TInputImage, class TOutputImage>
45 void
48 (const double inmean,const double invar,const double indifmean,
49  const double indifvar, const double inweight)
50 {
51  m_Mean = inmean;
52  m_Variance = invar;
53  m_Diff_Mean = indifmean;
54  m_Diff_Variance = indifvar;
55 
56  if(inweight < 0)
57  {
58  this->SetWeight(0);
59  }
60  else if(inweight > 1)
61  {
62  this->SetWeight(1);
63  }
64  else
65  {
66  this->SetWeight(inweight);
67  }
68 }
69 
70 template <class TInputImage, class TOutputImage>
71 double
74 {
75  double tmp1 = 0.5 * (f1 + f2) - m_Mean;
76  if(this->GetWeight() == 1)
77  {
78  return( (NumericTraits<unsigned short>::max())*
79  (vcl_exp(-0.5 * tmp1 * tmp1 / m_Variance)));
80  }
81  else
82  {
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)));
87  }
88 }
89 
90 template <class TInputImage, class TOutputImage>
91 void
93 ::PrintSelf(std::ostream& os, Indent indent) const
94 {
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;
100 
101 }
102 } /* end namespace itk. */
103 
104 
105 #endif

Generated at Sun Feb 3 2013 00:07:31 for Orfeo Toolbox with doxygen 1.8.1.1