find.bestBands: Find Best Band Combinations

View source: R/find.bestBands.R

find.bestBandsR Documentation

Find Best Band Combinations

Description

This function identifies the best band combination from the cm.nsr or cm.sr calculated correlation coefficients - a numeric matrix (2D), or the cm.rbd3 returned array (3D) by locating the maximum value in the input R and returning the corresponding wavelengths from w. For a 2D matrix, it returns a two-element vector (i, j); for a 3D array, a three-element vector (i, j, k).

Usage

find.bestBands(R, w)

Arguments

R

A numeric matrix (2D) or array (3D) containing metric values (e.g., correlation values).

w

A numeric vector of wavelengths corresponding to the bands.

Details

The function first verifies that R has dimensions. It then computes the maximum value in R, retrieves the indices corresponding to that value, and extracts the wavelengths from w based on the dimensionality of R. If R is 2D, the order is assumed to be (i, j); if R is 3D, the order is (i, j, k).

Value

A vector of wavelengths corresponding to the best band combination.

Examples

# Example for a 2D matrix:
R_mat <- matrix(c(0.2, 0.8, 0.5, 0.3), nrow = 2)
wavelengths <- c(450, 550)
bestBands <- find.bestBands(R_mat, wavelengths)

# Example for a 3D array:
R_arr <- array(runif(27), dim = c(3, 3, 3))
wavelengths <- c(400, 450, 500)
bestBands <- find.bestBands(R_arr, wavelengths)


visa documentation built on April 4, 2025, 5:40 a.m.