OTB  9.0.0
Orfeo Toolbox
otbBuiltUpIndicesFunctor.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 otbBuiltUpIndicesFunctor_h
22 #define otbBuiltUpIndicesFunctor_h
23 
24 #include "otbRadiometricIndex.h"
25 
26 namespace otb
27 {
28 namespace Functor
29 {
40 template <class TInput, class TOutput>
41 class ISU : public RadiometricIndex<TInput, TOutput>
42 {
43 public:
44  ISU() : RadiometricIndex<TInput, TOutput>({CommonBandNames::RED, CommonBandNames::NIR})
45  {
46  }
47 
48  TOutput operator()(const itk::VariableLengthVector<TInput>& input) const override
49  {
50  auto red = this->Value(CommonBandNames::RED, input);
51  auto nir = this->Value(CommonBandNames::NIR, input);
52 
53  if (nir == 0)
54  {
55  return static_cast<TOutput>(0.);
56  }
57 
58  return (static_cast<TOutput>(A - (B * red) / nir));
59  }
60 
61  static constexpr double A = 100.;
62  static constexpr double B = 25.;
63 };
64 
65 } // namespace Functor
66 } // namespace otb
67 
68 #endif
otb::Functor::RadiometricIndex::Value
double Value(BandNameType band, const itk::VariableLengthVector< TInput > &input) const
Definition: otbRadiometricIndex.h:204
otb::Functor::ISU::A
static constexpr double A
Definition: otbBuiltUpIndicesFunctor.h:61
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbRadiometricIndex.h
otb::Functor::ISU
This functor computes the Index surfaces built (ISU)
Definition: otbBuiltUpIndicesFunctor.h:41
otb::Functor::ISU::B
static constexpr double B
Definition: otbBuiltUpIndicesFunctor.h:62
otb::Functor::ISU::operator()
TOutput operator()(const itk::VariableLengthVector< TInput > &input) const override
Definition: otbBuiltUpIndicesFunctor.h:48
otb::Functor::RadiometricIndex
Base class for all radiometric indices.
Definition: otbRadiometricIndex.h:57
otb::Functor::ISU::ISU
ISU()
Definition: otbBuiltUpIndicesFunctor.h:44