OTB  5.0.0
Orfeo Toolbox
otbKullbackLeiblerProfileImageFilter.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  Some parts of this code are covered by the GET copyright.
13  See GETCopyright.txt for details.
14 
15 
16  This software is distributed WITHOUT ANY WARRANTY; without even
17  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18  PURPOSE. See the above copyright notices for more information.
19 
20 =========================================================================*/
21 #ifndef __otbKullbackLeiblerProfileImageFilter_h
22 #define __otbKullbackLeiblerProfileImageFilter_h
23 
24 #include <vector>
25 
26 #include "itkArray.h"
27 #include "itkArray2D.h"
29 
31 
32 namespace otb
33 {
34 
41 template <class TInput>
43 {
44 public:
46  typedef std::vector<CumulantType> CumulantSet;
47  typedef CumulantSet::iterator Iterator;
48 
49  CumulantsForEdgeworthProfile (const TInput& input, std::vector<itk::Array2D<int> >& mask);
51 
52  // Kullback-Leibler Profile
53  template <class TInput2>
55  // Kullback-Leibler divergence at a given scale
56  double KL_profile(const CumulantType& cumulants1, const CumulantType& cumulants2);
57  // Access to data
59  {
60  return this->fCum[i];
61  }
62  // Check data availability
63  inline bool IsDataAvailable() const
64  {
65  return this->fDataAvailable;
66  }
67 
68  // debug
69  int m_debug;
70 
71 protected:
72 
73  // Momentum Estimation from encapsulated neighborhood
74  int MakeSumAndMoments(const TInput& input, std::vector<itk::Array2D<int> >& mask);
75  // momentum estimation from the smaller window
76  int InitSumAndMoments(const TInput& input, itk::Array2D<int>& mask);
77  //
78  int ReInitSumAndMoments(const TInput& input, itk::Array2D<int>& mask, int level);
79  // transformation moment -> cumulants (for Edgeworth)
80  int MakeCumulants();
81 
82  // Internal variables
83  double fSum0, fSum1, fSum2, fSum3, fSum4;
86 
88 
89 private:
90  CumulantsForEdgeworthProfile (); // Not implemented
91  CumulantsForEdgeworthProfile (const TInput& input); // Not implemented
92 
93 };
94 
95 namespace Functor
96 {
103 template<class TInput1, class TInput2, class TOutput>
105 {
106 public:
109  // Gives the radius min and max of neighborhood
110  void SetRadius(const unsigned char& min, const unsigned char& max);
111  unsigned char GetRadiusMin(void);
112  unsigned char GetRadiusMax(void);
113  // Gives the size of the profile
115  {
116  return m_mask.size();
117  }
118  // functor
119  TOutput operator ()(const TInput1& it1, const TInput2& it2);
120 protected:
121  // Make the set of masks to play the increase in window size
122  void MakeMultiscaleProfile();
123  // Internal attributes
124  unsigned char m_RadiusMin;
125  unsigned char m_RadiusMax;
126  std::vector<itk::Array2D<int> > m_mask;
127 };
128 } // Functor
129 
162 template <class TInputImage1, class TInputImage2, class TOutputImage>
165  TInputImage1, TInputImage2, TOutputImage,
166  Functor::KullbackLeiblerProfile<
167  typename itk::ConstNeighborhoodIterator<TInputImage1>,
168  typename itk::ConstNeighborhoodIterator<TInputImage2>,
169  typename TOutputImage::PixelType> >
170 {
171 public:
174  typedef /*typename*/ BinaryFunctorNeighborhoodVectorImageFilter<
175  TInputImage1, TInputImage2, TOutputImage,
179  typename TOutputImage::PixelType>
183 
185  itkNewMacro(Self);
186 
187 protected:
190 
191 private:
192  KullbackLeiblerProfileImageFilter(const Self &); //purposely not implemented
193  void operator =(const Self&); //purposely not implemented
194 
195 };
196 
197 } // namespace otb
198 
199 #ifndef OTB_MANUAL_INSTANTIATION
201 #endif
202 
203 #endif
BinaryFunctorNeighborhoodVectorImageFilter< TInputImage1, TInputImage2, TOutputImage, Functor::KullbackLeiblerProfile< typename itk::ConstNeighborhoodIterator< TInputImage1 >, typename itk::ConstNeighborhoodIterator< TInputImage2 >, typename TOutputImage::PixelType > > Superclass
Implements neighborhood-wise generic operation of two images beeing vector images.
int InitSumAndMoments(const TInput &input, itk::Array2D< int > &mask)
int MakeSumAndMoments(const TInput &input, std::vector< itk::Array2D< int > > &mask)
Implements neighborhood-wise the computation of KullbackLeibler profile over Edgeworth approximation...
void SetRadius(const unsigned char &min, const unsigned char &max)
itk::VariableLengthVector< double > KL_profile(CumulantsForEdgeworthProfile< TInput2 > &cumulants)
TOutput operator()(const TInput1 &it1, const TInput2 &it2)
Functor for KullbackLeiblerProfileImageFilter. Please refer to KullbackLeiblerProfileImageFilter.
Helper class for KullbackLeiblerProfileImageFilter. Please refer to KullbackLeibleProfileImageFilter...
int ReInitSumAndMoments(const TInput &input, itk::Array2D< int > &mask, int level)