OTB  9.0.0
Orfeo Toolbox
otbPointSetDensityEpanechnikovFunction.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 otbPointSetDensityEpanechnikovFunction_hxx
22 #define otbPointSetDensityEpanechnikovFunction_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  if (distsq < radiussq)
51  {
52  accu += 0.75 * (1 - distsq / radiussq);
53  }
54  ++it;
55  }
56  }
57 
58  return accu;
59 }
60 
64 template <class TPointSet, class TOutput>
65 void PointSetDensityEpanechnikovFunction<TPointSet, TOutput>::PrintSelf(std::ostream& os, itk::Indent indent) const
66 {
67  this->Superclass::PrintSelf(os, indent);
68 }
69 
70 } // end namespace otb
71 
72 #endif
otb::PointSetDensityEpanechnikovFunction::Evaluate
OutputType Evaluate(const InputType &input) const override
Definition: otbPointSetDensityEpanechnikovFunction.hxx:34
otb::PointSetDensityEpanechnikovFunction::InputType
Superclass::InputType InputType
Definition: otbPointSetDensityEpanechnikovFunction.h:58
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbPointSetDensityEpanechnikovFunction.h
otb::PointSetDensityEpanechnikovFunction::OutputType
TOutput OutputType
Definition: otbPointSetDensityEpanechnikovFunction.h:62
otb::PointSetDensityEpanechnikovFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbPointSetDensityEpanechnikovFunction.hxx:65