OTB  9.0.0
Orfeo Toolbox
otbPolygonCompacityFunctor.h
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 otbPolygonCompacityFunctor_h
22 #define otbPolygonCompacityFunctor_h
23 
24 #include "otbMath.h"
25 
26 namespace otb
27 {
28 
46 template <class TInput1>
48 {
49 public:
50  void SetThreshold(double threshold)
51  {
52  m_Threshold = threshold;
53  }
54  double GetThreshold(void) const
55  {
56  return m_Threshold;
57  }
58 
60  {
61  m_Threshold = 0.2;
62  }
64  {
65  }
66 
67  inline bool operator()(const TInput1& input)
68  {
69  double circularityRatio = 4 * CONST_PI * input->GetArea() / vnl_math_sqr(input->GetLength());
70 
71  if (circularityRatio > m_Threshold)
72  {
73  return true;
74  }
75  else
76  {
77  return false;
78  }
79  }
80 
81 private:
82  double m_Threshold;
83 };
84 }
85 
86 #endif
otb::CONST_PI
constexpr double CONST_PI
Definition: otbMath.h:49
otb::PolygonCompacityFunctor::~PolygonCompacityFunctor
~PolygonCompacityFunctor()
Definition: otbPolygonCompacityFunctor.h:63
otb::PolygonCompacityFunctor
Select polygons according to their compacity.
Definition: otbPolygonCompacityFunctor.h:47
otb::PolygonCompacityFunctor::PolygonCompacityFunctor
PolygonCompacityFunctor()
Definition: otbPolygonCompacityFunctor.h:59
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::PolygonCompacityFunctor::SetThreshold
void SetThreshold(double threshold)
Definition: otbPolygonCompacityFunctor.h:50
otb::PolygonCompacityFunctor::m_Threshold
double m_Threshold
Definition: otbPolygonCompacityFunctor.h:82
otb::PolygonCompacityFunctor::operator()
bool operator()(const TInput1 &input)
Definition: otbPolygonCompacityFunctor.h:67
otb::PolygonCompacityFunctor::GetThreshold
double GetThreshold(void) const
Definition: otbPolygonCompacityFunctor.h:54