View source: R/find.bestBands.R
find.bestBands | R Documentation |
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).
find.bestBands(R, w)
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. |
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).
A vector of wavelengths corresponding to the best band combination.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.