OTB  9.0.0
Orfeo Toolbox
otbKullbackLeiblerDistanceImageFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  * Copyright (C) 2007-2012 Institut Mines Telecom / Telecom Bretagne
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbKullbackLeiblerDistanceImageFilter_h
23 #define otbKullbackLeiblerDistanceImageFilter_h
24 
25 #include "itkVariableLengthVector.h"
27 
28 namespace otb
29 {
30 
37 template <class TInput>
39 {
40 public:
41  CumulantsForEdgeworth(const TInput& input);
42  CumulantsForEdgeworth(const itk::Image<typename TInput::ImageType::PixelType, 1>* input);
44  {
45  }
46 
48  template <class TInput2>
49  double Divergence(const CumulantsForEdgeworth<TInput2>& cumulants);
50 
51  inline double GetMean() const
52  {
53  return this->fMean;
54  }
55  inline double GetVariance() const
56  {
57  return this->fVariance;
58  }
59  inline double GetSkewness() const
60  {
61  return this->fSkewness;
62  }
63  inline double GetKurtosis() const
64  {
65  return this->fKurtosis;
66  }
67  inline bool IsDataAvailable() const
68  {
69  return this->fDataAvailable;
70  }
71 
72 protected:
74  void MakeSumAndMoments(const TInput& input);
75 
77  void MakeSumAndMoments(const itk::Image<typename TInput::ImageType::PixelType, 1>* input);
78 
80  void MakeCumulants();
81 
82  double fSum0, fSum1, fSum2, fSum3, fSum4;
83  double fMu1, fMu2, fMu3, fMu4;
85 
87 };
88 
89 namespace Functor
90 {
97 template <class TInput1, class TInput2, class TOutput>
99 {
100 public:
102  {
103  }
105  {
106  }
107  TOutput operator()(const TInput1& it1, const TInput2& it2)
108  {
110  if (!cum1.IsDataAvailable())
111  return static_cast<TOutput>(0.);
112 
114  if (!cum2.IsDataAvailable())
115  return static_cast<TOutput>(0.);
116 
117  return static_cast<TOutput>(cum1.Divergence(cum2) + cum2.Divergence(cum1));
118  }
119 };
120 
121 } // Functor
122 
154 template <class TInputImage1, class TInputImage2, class TOutputImage>
157  TInputImage1, TInputImage2, TOutputImage,
158  Functor::KullbackLeiblerDistance<typename itk::ConstNeighborhoodIterator<TInputImage1>, typename itk::ConstNeighborhoodIterator<TInputImage2>,
159  typename TOutputImage::PixelType>>
160 {
161 public:
165  TInputImage1, TInputImage2, TOutputImage,
166  Functor::KullbackLeiblerDistance<typename itk::ConstNeighborhoodIterator<TInputImage1>, typename itk::ConstNeighborhoodIterator<TInputImage2>,
167  typename TOutputImage::PixelType>>
169  typedef itk::SmartPointer<Self> Pointer;
170  typedef itk::SmartPointer<const Self> ConstPointer;
171 
173  itkNewMacro(Self);
174 
175 protected:
177  {
178  }
180  {
181  }
182 
183 private:
184  KullbackLeiblerDistanceImageFilter(const Self&) = delete;
185  void operator=(const Self&) = delete;
186 };
187 
188 } // namespace otb
189 
190 #ifndef OTB_MANUAL_INSTANTIATION
192 #endif
193 
194 #endif
otb::CumulantsForEdgeworth::MakeCumulants
void MakeCumulants()
Definition: otbKullbackLeiblerDistanceImageFilter.hxx:245
otb::BinaryFunctorNeighborhoodImageFilter
Implements neighborhood-wise generic operation of two images.
Definition: otbBinaryFunctorNeighborhoodImageFilter.h:47
otb::KullbackLeiblerDistanceImageFilter::KullbackLeiblerDistanceImageFilter
KullbackLeiblerDistanceImageFilter()
Definition: otbKullbackLeiblerDistanceImageFilter.h:176
otb::CumulantsForEdgeworth::fMu2
double fMu2
Definition: otbKullbackLeiblerDistanceImageFilter.h:83
otb::CumulantsForEdgeworth::GetVariance
double GetVariance() const
Definition: otbKullbackLeiblerDistanceImageFilter.h:55
otb::CumulantsForEdgeworth::CumulantsForEdgeworth
CumulantsForEdgeworth(const TInput &input)
Definition: otbKullbackLeiblerDistanceImageFilter.hxx:40
otb::Functor::KullbackLeiblerDistance::operator()
TOutput operator()(const TInput1 &it1, const TInput2 &it2)
Definition: otbKullbackLeiblerDistanceImageFilter.h:107
otb::CumulantsForEdgeworth::fSum1
double fSum1
Definition: otbKullbackLeiblerDistanceImageFilter.h:82
otb::KullbackLeiblerDistanceImageFilter::Self
KullbackLeiblerDistanceImageFilter Self
Definition: otbKullbackLeiblerDistanceImageFilter.h:163
otb::CumulantsForEdgeworth::GetMean
double GetMean() const
Definition: otbKullbackLeiblerDistanceImageFilter.h:51
otb::Functor::KullbackLeiblerDistance::KullbackLeiblerDistance
KullbackLeiblerDistance()
Definition: otbKullbackLeiblerDistanceImageFilter.h:101
otb::CumulantsForEdgeworth::GetKurtosis
double GetKurtosis() const
Definition: otbKullbackLeiblerDistanceImageFilter.h:63
otb::Functor::KullbackLeiblerDistance
Functor for KullbackLeiblerDistanceImageFilter. Please refer to KullbackLeiblerDistanceImageFilter.
Definition: otbKullbackLeiblerDistanceImageFilter.h:98
otb::CumulantsForEdgeworth::GetSkewness
double GetSkewness() const
Definition: otbKullbackLeiblerDistanceImageFilter.h:59
otb::CumulantsForEdgeworth::fSum0
double fSum0
Definition: otbKullbackLeiblerDistanceImageFilter.h:82
otb::KullbackLeiblerDistanceImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbKullbackLeiblerDistanceImageFilter.h:169
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbBinaryFunctorNeighborhoodImageFilter.h
otb::KullbackLeiblerDistanceImageFilter::~KullbackLeiblerDistanceImageFilter
~KullbackLeiblerDistanceImageFilter() override
Definition: otbKullbackLeiblerDistanceImageFilter.h:179
otb::CumulantsForEdgeworth::fMean
double fMean
Definition: otbKullbackLeiblerDistanceImageFilter.h:84
otb::CumulantsForEdgeworth
Helper class for KullbackLeiblerDistanceImageFilter. Please refer to KullbackLeiblerDistanceImageFilt...
Definition: otbKullbackLeiblerDistanceImageFilter.h:38
otb::CumulantsForEdgeworth::fMu3
double fMu3
Definition: otbKullbackLeiblerDistanceImageFilter.h:83
otb::CumulantsForEdgeworth::fSum2
double fSum2
Definition: otbKullbackLeiblerDistanceImageFilter.h:82
otb::CumulantsForEdgeworth::MakeSumAndMoments
void MakeSumAndMoments(const TInput &input)
Definition: otbKullbackLeiblerDistanceImageFilter.hxx:109
otb::CumulantsForEdgeworth::fSum4
double fSum4
Definition: otbKullbackLeiblerDistanceImageFilter.h:82
otb::KullbackLeiblerDistanceImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbKullbackLeiblerDistanceImageFilter.h:170
otb::CumulantsForEdgeworth::Divergence
double Divergence(const CumulantsForEdgeworth< TInput2 > &cumulants)
Definition: otbKullbackLeiblerDistanceImageFilter.hxx:57
otb::CumulantsForEdgeworth::IsDataAvailable
bool IsDataAvailable() const
Definition: otbKullbackLeiblerDistanceImageFilter.h:67
otb::CumulantsForEdgeworth::fVariance
double fVariance
Definition: otbKullbackLeiblerDistanceImageFilter.h:84
otb::CumulantsForEdgeworth::fSkewness
double fSkewness
Definition: otbKullbackLeiblerDistanceImageFilter.h:84
otb::CumulantsForEdgeworth::fMu4
double fMu4
Definition: otbKullbackLeiblerDistanceImageFilter.h:83
otb::CumulantsForEdgeworth::fMu1
double fMu1
Definition: otbKullbackLeiblerDistanceImageFilter.h:83
otb::CumulantsForEdgeworth::fKurtosis
double fKurtosis
Definition: otbKullbackLeiblerDistanceImageFilter.h:84
otb::CumulantsForEdgeworth::fSum3
double fSum3
Definition: otbKullbackLeiblerDistanceImageFilter.h:82
otb::KullbackLeiblerDistanceImageFilter::Superclass
otb::BinaryFunctorNeighborhoodImageFilter< TInputImage1, TInputImage2, TOutputImage, Functor::KullbackLeiblerDistance< typename itk::ConstNeighborhoodIterator< TInputImage1 >, typename itk::ConstNeighborhoodIterator< TInputImage2 >, typename TOutputImage::PixelType > > Superclass
Definition: otbKullbackLeiblerDistanceImageFilter.h:168
otb::Functor::KullbackLeiblerDistance::~KullbackLeiblerDistance
virtual ~KullbackLeiblerDistance()
Definition: otbKullbackLeiblerDistanceImageFilter.h:104
otbKullbackLeiblerDistanceImageFilter.hxx
otb::CumulantsForEdgeworth::fDataAvailable
bool fDataAvailable
Definition: otbKullbackLeiblerDistanceImageFilter.h:86
otb::CumulantsForEdgeworth::~CumulantsForEdgeworth
virtual ~CumulantsForEdgeworth()
Definition: otbKullbackLeiblerDistanceImageFilter.h:43
otb::KullbackLeiblerDistanceImageFilter
Implements neighborhood-wise the computation of KullbackLeibler distance over Edgeworth approximation...
Definition: otbKullbackLeiblerDistanceImageFilter.h:155