Go to the documentation of this file.
14 static int32_t idx_band_ir = -1;
16 static int idx_multiband_nir;
18 static int idx_nir_min =
BAD_INT;
19 static int idx_nir_max =
BAD_INT;
21 static int32_t num_bands;
33 int32_t idx_pixel = -0, idx_band = -0;
34 float rhos_nir = -0.0, rhos_ir = -0.0;
37 if (idx_nir_max < 0 || idx_nir_min < 0 || idx_band_ir < 0) {
38 printf(
"NDII requires NIR bands between 670 and 875, and at 1618 nm");
42 for (idx_pixel = 0; idx_pixel <
l1rec->npix; idx_pixel++) {
44 idx_band =
l1rec->l1file->nbands * idx_pixel;
49 float *start_of_rhos_nir = &
l1rec->rhos[idx_band + idx_nir_min];
50 int nir_band_width = idx_nir_max - idx_nir_min + 1;
53 rhos_ir =
l1rec->rhos[idx_band + idx_band_ir];
56 rhos_nir =
l1rec->rhos[idx_band + idx_multiband_nir];
57 rhos_ir =
l1rec->rhos[idx_band + idx_band_ir];
61 double pixel_elevation =
l1rec->dem[idx_pixel];
63 double rhos_vals[] = {rhos_nir, rhos_ir};
64 int len =
sizeof(rhos_vals) /
sizeof(rhos_vals[0]);
66 if (
invalid_pixel(pixel_elevation, pixel_mask, rhos_vals, len)) {
71 float ndii_value = (rhos_nir - rhos_ir) / (rhos_nir + rhos_ir);
82 num_bands =
l1rec->l1file->nbands;
84 static bool first_call =
true;
void calculate_ndii(l1str *l1rec, float ndii[])
void get_ndii(l1str *l1rec, float prod[])
Main entry point for getting ndii.
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.
bool instrument_is_hyperspectral(int32_t num_bands)
float clamp(float pixel_value, int minimum, int maximum)
Clamp the value of a pixel between minval and maxval.