forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsavi.c
32 lines (29 loc) · 944 Bytes
/
msavi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* MSAVI: Modified Soil Adjusted Vegetation Index
*
* s(NIR-s*red-a)
* MSAVI = ---------------------------
* (a*NIR+red-a*s+X*(1+s*s))
* where a is the soil line intercept, s is the
* soil line slope, and X is an adjustment factor
* which is set to minimize soil noise (0.08 in
* original papers).
*/
double msa_vi(double redchan, double nirchan, double soil_line_slope,
double soil_line_intercept, double soil_noise_reduction_factor)
{
double result, a, s, X;
s = soil_line_slope;
a = soil_line_intercept;
X = soil_noise_reduction_factor;
if ((nirchan + redchan) == 0.0) {
result = -1.0;
}
else {
result = s * (nirchan - s * redchan - a) /
(a * nirchan + redchan - a * s + X * (1 + s + s));
}
return result;
}