OTB  9.0.0
Orfeo Toolbox
otbPointSetDensityGaussianFunction.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 #ifndef otbPointSetDensityGaussianFunction_hxx
22 #define otbPointSetDensityGaussianFunction_hxx
23 
25 #include "otbMath.h"
26 
27 namespace otb
28 {
32 template <class TPointSet, class TOutput>
35 {
36  double accu = 0;
37  double radiussq = m_Radius * m_Radius;
38 
39  if (this->GetPointSet()->GetNumberOfPoints() != 0)
40  {
41  typedef typename TPointSet::PointsContainer::ConstIterator iteratorType;
42  iteratorType it = this->GetPointSet()->GetPoints()->Begin();
43 
44  while (it != this->GetPointSet()->GetPoints()->End())
45  {
46  float distX = input[0] - it.Value()[0];
47  float distY = input[1] - it.Value()[1];
48  float distsq = distX * distX + distY * distY;
49 
50  accu += std::exp(-distsq / radiussq / 2);
51 
52  ++it;
53  }
54  accu /= std::sqrt(2 * CONST_PI * radiussq);
55  }
56 
57  return accu;
58 }
59 
63 template <class TPointSet, class TOutput>
64 void PointSetDensityGaussianFunction<TPointSet, TOutput>::PrintSelf(std::ostream& os, itk::Indent indent) const
65 {
66  this->Superclass::PrintSelf(os, indent);
67 }
68 
69 } // end namespace otb
70 
71 #endif
otb::CONST_PI
constexpr double CONST_PI
Definition: otbMath.h:49
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PointSetDensityGaussianFunction::Evaluate
OutputType Evaluate(const InputType &input) const override
Definition: otbPointSetDensityGaussianFunction.hxx:34
otb::PointSetDensityGaussianFunction::OutputType
TOutput OutputType
Definition: otbPointSetDensityGaussianFunction.h:62
otb::PointSetDensityGaussianFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbPointSetDensityGaussianFunction.hxx:64
otb::PointSetDensityGaussianFunction::InputType
Superclass::InputType InputType
Definition: otbPointSetDensityGaussianFunction.h:58
otbPointSetDensityGaussianFunction.h