21 #ifndef otbVegetationIndicesFunctor_h
22 #define otbVegetationIndicesFunctor_h
42 template <
class TInput,
class TOutput>
50 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
52 auto red = this->
Value(CommonBandNames::RED, input);
53 auto nir = this->
Value(CommonBandNames::NIR, input);
55 return static_cast<TOutput
>(
Compute(red, nir));
59 static double Compute(
const double& red,
const double& nir)
66 return (nir - red) / (nir + red);
80 template <
class TInput,
class TOutput>
88 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
90 auto red = this->
Value(CommonBandNames::RED, input);
91 auto nir = this->
Value(CommonBandNames::NIR, input);
95 return static_cast<TOutput
>(0.);
97 return (
static_cast<TOutput
>(nir / red));
115 template <
class TInput,
class TOutput>
123 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
125 auto red = this->
Value(CommonBandNames::RED, input);
126 auto nir = this->
Value(CommonBandNames::NIR, input);
128 return (
static_cast<TOutput
>((nir -
A * red -
B) *
C));
132 static constexpr
double A = 0.90893;
133 static constexpr
double B = 7.46216;
134 static constexpr
double C = 9.74;
147 template <
class TInput,
class TOutput>
155 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
157 auto red = this->
Value(CommonBandNames::RED, input);
158 auto nir = this->
Value(CommonBandNames::NIR, input);
162 return static_cast<TOutput
>(0.);
164 return (
static_cast<TOutput
>(((nir - red) * (1 +
L)) / (nir + red +
L)));
168 static constexpr
double L = 0.5;
181 template <
class TInput,
class TOutput>
189 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
191 auto red = this->
Value(CommonBandNames::RED, input);
192 auto nir = this->
Value(CommonBandNames::NIR, input);
194 double denominator =
A * nir + red +
X * (1. +
A *
A);
198 return static_cast<TOutput
>(0.);
200 return (
static_cast<TOutput
>((
A * (nir -
A * red -
S)) / denominator));
204 static constexpr
double A = 0.7;
205 static constexpr
double S = 0.9;
208 static constexpr
double X = 0.08;
221 template <
class TInput,
class TOutput>
230 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
232 auto red = this->
Value(CommonBandNames::RED, input);
233 auto nir = this->
Value(CommonBandNames::NIR, input);
235 return static_cast<TOutput
>(
Compute(red, nir));
238 static double Compute(
const double& red,
const double& nir)
240 return (nir -
S * red);
244 static constexpr
double S = 0.4;
258 template <
class TInput,
class TOutput>
266 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
268 auto red = this->
Value(CommonBandNames::RED, input);
269 auto nir = this->
Value(CommonBandNames::NIR, input);
274 double L = 1 - 2 *
S *
ndvi * wdvi;
276 double denominator = nir + red + L;
280 return static_cast<TOutput
>(0.);
283 return (
static_cast<TOutput
>(((nir - red) * (1 + L)) / denominator));
288 static constexpr
double S = 0.4;
301 template <
class TInput,
class TOutput>
309 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
311 auto red = this->
Value(CommonBandNames::RED, input);
312 auto nir = this->
Value(CommonBandNames::NIR, input);
314 double sqrt_value = (2 * nir + 1) * (2 * nir + 1) - 8 * (nir - red);
317 return static_cast<TOutput
>(0.);
319 return (
static_cast<TOutput
>((2 * nir + 1 - std::sqrt(sqrt_value)) / 2.));
333 template <
class TInput,
class TOutput>
341 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
343 auto red = this->
Value(CommonBandNames::RED, input);
344 auto nir = this->
Value(CommonBandNames::NIR, input);
348 double denom_nu = nir + red + 0.5;
356 num_nu = 2 * (nir * nir - red * red) + 1.5 * nir + 0.5 * red;
357 nu = num_nu / denom_nu;
360 double denom_GEMI = 1 - red;
363 return static_cast<TOutput
>(0.);
365 return (
static_cast<TOutput
>((nu * (1 - 0.25 * nu) - (red - 0.125)) / denom_GEMI));
381 template <
class TInput,
class TOutput>
385 AVI() :
RadiometricIndex<TInput, TOutput>({CommonBandNames::GREEN, CommonBandNames::RED, CommonBandNames::NIR})
389 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
391 auto green = this->
Value(CommonBandNames::GREEN, input);
392 auto red = this->
Value(CommonBandNames::RED, input);
393 auto nir = this->
Value(CommonBandNames::NIR, input);
405 dterm1 = std::atan(dfact1 / (nir - red));
414 dterm2 = std::atan(dfact2 / (green - red));
417 return static_cast<TOutput
>(dterm1 + dterm2);
442 template <
class TInput,
class TOutput>
446 ARVI() :
RadiometricIndex<TInput, TOutput>({CommonBandNames::BLUE, CommonBandNames::RED, CommonBandNames::NIR})
450 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
452 auto blue = this->
Value(CommonBandNames::BLUE, input);
453 auto red = this->
Value(CommonBandNames::RED, input);
454 auto nir = this->
Value(CommonBandNames::NIR, input);
456 double RHOrb = red -
Gamma * (blue - red);
457 double denominator = nir + RHOrb;
460 return static_cast<TOutput
>(0.);
462 return (
static_cast<TOutput
>((nir - RHOrb) / denominator));
466 static constexpr
double Gamma = 0.5;
481 template <
class TInput,
class TOutput>
485 EVI() :
RadiometricIndex<TInput, TOutput>({CommonBandNames::BLUE, CommonBandNames::RED, CommonBandNames::NIR})
489 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
491 auto blue = this->
Value(CommonBandNames::BLUE, input);
492 auto red = this->
Value(CommonBandNames::RED, input);
493 auto nir = this->
Value(CommonBandNames::NIR, input);
495 double denominator = nir +
C1 * red -
C2 * blue +
L;
498 return (
static_cast<TOutput
>(0.));
500 return (
static_cast<TOutput
>(
G * (nir - red) / denominator));
504 static constexpr
double G = 2.5;
507 static constexpr
double C1 = 6.0;
510 static constexpr
double C2 = 7.5;
513 static constexpr
double L = 1.0;
526 template <
class TInput,
class TOutput>
534 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
536 auto red = this->
Value(CommonBandNames::RED, input);
537 auto nir = this->
Value(CommonBandNames::NIR, input);
541 return static_cast<TOutput
>(0.);
545 return (
static_cast<TOutput
>(nir / (nir + red)));
560 template <
class TInput,
class TOutput>
568 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
570 auto red = this->
Value(CommonBandNames::RED, input);
571 auto nir = this->
Value(CommonBandNames::NIR, input);
577 return (
static_cast<TOutput
>(0));
581 return (
static_cast<TOutput
>(std::sqrt(val)));
602 template <
class TInput,
class TOutput>
641 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
643 auto red = this->
Value(CommonBandNames::RED, input);
644 auto nir = this->
Value(CommonBandNames::NIR, input);
650 return (
static_cast<TOutput
>(0));
681 template <
class TInput,
class TOutput>
709 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
711 auto red = this->
Value(CommonBandNames::RED, input);
712 auto nir = this->
Value(CommonBandNames::NIR, input);
741 template <
class TInput,
class TOutput>
749 TOutput
operator()(
const itk::VariableLengthVector<TInput>& input)
const override
751 auto red = this->
Value(CommonBandNames::RED, input);
752 auto nir = this->
Value(CommonBandNames::NIR, input);
756 return static_cast<TOutput
>(0.);
758 return static_cast<TOutput
>(
A * (std::exp((nir - red) / (red + nir) *
B) - std::exp(
C *
B)));
761 static constexpr
double A = 0.1519;
762 static constexpr
double B = 3.9443;
763 static constexpr
double C = 0.13;