Go to the documentation of this file.
16 static int32_t
sensor = -0;
17 static int32_t num_bands;
18 static int32_t idx_band_ir = -1;
19 static int idx_multiband_grn = -1;
21 static int idx_grn_min =
BAD_INT;
22 static int idx_grn_max =
BAD_INT;
31 int32_t idx_pixel = -0, idx_band = -0;
32 float rhos_grn = -0.0, rhos_ir = -0.0;
35 if (idx_grn_max < 0 || idx_grn_min < 0 || idx_band_ir < 0) {
36 printf(
"NDSI requires bands near 555 and 1618 nm");
40 for (idx_pixel = 0; idx_pixel <
l1rec->npix; idx_pixel++) {
42 idx_band =
l1rec->l1file->nbands * idx_pixel;
47 float *start_of_rhos_grn = &
l1rec->rhos[idx_band + idx_grn_min];
48 int grn_band_width = idx_grn_max - idx_grn_min + 1;
53 rhos_grn =
l1rec->rhos[idx_band + idx_multiband_grn];
55 rhos_ir =
l1rec->rhos[idx_band + idx_band_ir];
58 double pixel_elevation =
l1rec->dem[idx_pixel];
60 double rhos_vals[] = {rhos_grn, rhos_ir};
61 int len =
sizeof(rhos_vals) /
sizeof(rhos_vals[0]);
63 if (
invalid_pixel(pixel_elevation, pixel_mask, rhos_vals, len)) {
68 float ndsi_value = (rhos_grn - rhos_ir) / (rhos_grn + rhos_ir);
74 sensor =
l1rec->l1file->sensorID;
75 num_bands =
l1rec->l1file->nbands;
77 static bool first_call =
true;
float average_rhos_values(float rhos_values[], size_t length)
Get the average of rho_s values from a hyperspectral measurement to approximate a multi-band measurem...
int bindex_get(int32_t wave)
bool invalid_pixel(double pixel_elevation, double pixel_mask, double rhos_values[], int len_rhos_values)
Check pixel attributes for validity.
void get_ndsi(l1str *l1rec, float ndsi[])
bool instrument_is_hyperspectral(int32_t num_bands)
const int32_t modis_b4_max
void calculate_ndsi(l1str *l1rec, float ndsi[])
const int32_t modis_b4_min
float clamp(float pixel_value, int minimum, int maximum)
Clamp the value of a pixel between minval and maxval.