All the N-FINDR techniques are based on the fact that, in N spectral dimensions, the N-volume contained by a simplex formed of the purest pixels is larger than any other volume formed from any other combination of pixels.

nfindr(x, ...)

# S3 method for default
nfindr(
  x,
  p,
  indices = sample(nrow(data), p),
  iter = c("points", "endmembers", "both"),
  estimator = c("Cramer", "volume", "height", "cofactor", "LDU"),
  iter_max = 10,
  keep_data = TRUE,
  debug.level = 0,
  ...
)

# S3 method for formula
nfindr(formula, frame, ...)

Arguments

x

Data to unmix. It will be converted to a matrix using as.matrix. The matrix should contain a spectrum per row. If the dimension of the data is larger than `p-1` then it will be dimensionally reduced using PCA. If you want to reduce the data using some other method then reduce it first and provide the data of `p-1` dimension.

...

Parameters to be passed to nfindr.default

p

Number of endmembers.

indices

Locations of the rows in the dataset that will be used to form the initial simplex. Default: Randomly selected indices.

iter

The iteration strategy. Options: "points", "endmembers", "both". By default, "points" are used.

estimator

Volume change estimator

  • volume - straight forward volume calculation without any optimization

  • height - Use the fact that the simplex volume is proportional to the product of `height` and `base volume`.

  • Cramer - Using Cramer's rule

  • LDU - Using LDU matrix decomposition

  • cofactor - Using the cofactor expansion for calculating `det(E)`

Default: Cramer's rules is used since it has best performance.

iter_max

Maximum number of iterations to make.

keep_data

Boolean that indicates whether the actual data used for the calculation (i.e. after dimension reduction) should be stored in the resulting structure.

debug.level

Debug level. Controls the level of detalization of the output. By default, is 0. If it is 1, then number of replacements also will be returned. 2 - also will add list of vertices at each iteration.

formula

A formula object without a response term

frame

A data frame containing the variables in the model

Value

A list which contains:

  • data: the original data or reduced data if keep_data is set to TRUE.

  • indices: the indices of the spectra which increased the simplex volume the most. These are the indices of the endmembers.

  • endmembers: the vectors of endmembers in reduced data space.

  • iterations_count: if debug level higher than 0, number of loop iterations.

  • replacements_count: if debug level higher than 0, number of actual replacements during iterations.

  • replacements: if debug level higher than 1, the vectors of indices at all replacement steps. If fact, is used to see how the simplex was growing.

See also

endmembers to extract the spectra; predict to determine abundances of endmembers in each sample.

Examples

data(demo_data)
demo <- nfindr(demo_data, 2)
em <- demo_data[demo$indices,]
em <- rbind(demo_data[c(3,7),], em)
em[3:4,] <- em[3:4,] + 0.5 # a small offset for the found em's
matplot(t(em), type = "l",
   col = c("black", "red", "black", "red"), lty = c(1, 1, 2, 2),
   xlab = "frequency", ylab = "intensity",
   main = "N-FINDR of demo_data")
leg.txt <- c("Endmember 1", "Endmember 2", "Endmember 1 (found)", "Endmember 2 (found)")
legend("topright", leg.txt, col = c("black", "red", "black", "red"),
lty = c(1, 1, 2, 2), cex = 0.75)