OTB  6.7.0
Orfeo Toolbox
otbHistogramStatisticsFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 
22 #ifndef otbHistogramStatisticsFunction_h
23 #define otbHistogramStatisticsFunction_h
24 
25 #include "itkNumericTraits.h"
27 
28 namespace otb
29 {
30 
43 template<class TInputHistogram, class TOutput>
45  public itk::HistogramAlgorithmBase<TInputHistogram>
46 {
47 public:
53 
54  typedef typename TInputHistogram::MeasurementType MeasurementType;
55  typedef typename TInputHistogram::AbsoluteFrequencyType FrequencyType; //FIXME several possibilities in the new framework
57 
59  itkTypeMacro(HistogramStatisticsFunction, HistogramAlgorithmsBase);
60  itkNewMacro(Self);
62 
64  typedef std::vector<TOutput> OutputType;
65 
68 
71 
74 
76  void SetInputHistogram(const TInputHistogram * histogram)
77  {
78  if (m_InputHistogram != histogram)
79  {
80  m_InputHistogram = histogram;
81  this->Modified();
82  m_IsModified = true;
83  }
84  }
86 
88  void Compute() override
89  {
90  this->GenerateData();
91  }
92 
93 protected:
94 
97  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
98 
100  void GenerateData();
101 
103  void CalculateEntropy();
104 
106  void CalculateMean();
107 
109  void CalculateCovariance();
110 
111 
112 
113 private:
114 
119 
121  typename TInputHistogram::ConstPointer m_InputHistogram;
122 
123 }; // end of class
124 
125 } // end of namespace otb
126 
127 #ifndef OTB_MANUAL_INSTANTIATION
129 #endif
130 
131 #endif
itk::NumericTraits< MeasurementType >::RealType RealType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
itk::SmartPointer< const Self > ConstPointer
TInputHistogram::ConstPointer m_InputHistogram
TInputHistogram::AbsoluteFrequencyType FrequencyType
itk::HistogramAlgorithmBase< TInputHistogram > Superclass
virtual void Modified() const
TInputHistogram::MeasurementType MeasurementType
Computes parameters for a histogram.
void SetInputHistogram(const TInputHistogram *histogram)