Orfeo Toolbox  4.0
otbKullbackLeiblerDistanceImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12  Copyright (c) Institut Telecom / Telecom Bretagne. All rights reserved.
13  See GETCopyright.txt for details.
14 
15  This software is distributed WITHOUT ANY WARRANTY; without even
16  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17  PURPOSE. See the above copyright notices for more information.
18 
19 =========================================================================*/
20 #ifndef __otbKullbackLeiblerDistanceImageFilter_h
21 #define __otbKullbackLeiblerDistanceImageFilter_h
22 
25 
26 namespace otb
27 {
28 
33 template <class TInput>
35 {
36 public:
37  CumulantsForEdgeworth (const TInput& input);
39  virtual ~CumulantsForEdgeworth () {}
40 
42  template <class TInput2>
43  double Divergence(const CumulantsForEdgeworth<TInput2>& cumulants);
44 
45  inline double GetMean() const
46  {
47  return this->fMean;
48  }
49  inline double GetVariance() const
50  {
51  return this->fVariance;
52  }
53  inline double GetSkewness() const
54  {
55  return this->fSkewness;
56  }
57  inline double GetKurtosis() const
58  {
59  return this->fKurtosis;
60  }
61  inline bool IsDataAvailable() const
62  {
63  return this->fDataAvailable;
64  }
65 
66 protected:
67 
69  void MakeSumAndMoments(const TInput& input);
73  void MakeCumulants();
74 
75  double fSum0, fSum1, fSum2, fSum3, fSum4;
76  double fMu1, fMu2, fMu3, fMu4;
78 
80 };
81 
82 namespace Functor
83 {
88 template <class TInput1, class TInput2, class TOutput>
90 {
91 public:
94  TOutput operator ()(const TInput1& it1, const TInput2& it2)
95  {
97  if (!cum1.IsDataAvailable()) return static_cast<TOutput>(0.);
98 
100  if (!cum2.IsDataAvailable()) return static_cast<TOutput>(0.);
101 
102  return static_cast<TOutput> (cum1.Divergence(cum2)
103  + cum2.Divergence(cum1));
104  }
105 };
106 
107 } // Functor
108 
138 template <class TInputImage1, class TInputImage2, class TOutputImage>
141  TInputImage1, TInputImage2, TOutputImage,
142  Functor::KullbackLeiblerDistance<
143  typename itk::ConstNeighborhoodIterator<TInputImage1>,
144  typename itk::ConstNeighborhoodIterator<TInputImage2>,
145  typename TOutputImage::PixelType> >
146 {
147 public:
151  TInputImage1, TInputImage2, TOutputImage,
155  typename TOutputImage::PixelType>
159 
161  itkNewMacro(Self);
162 
163 protected:
166 
167 private:
168  KullbackLeiblerDistanceImageFilter(const Self &); //purposely not implemented
169  void operator =(const Self&); //purposely not implemented
170 
171 };
172 
173 } // namespace otb
174 
175 #ifndef OTB_MANUAL_INSTANTIATION
177 #endif
178 
179 #endif

Generated at Sat Mar 8 2014 16:03:07 for Orfeo Toolbox with doxygen 1.8.3.1