Search code examples
rfilteringsmoothing

Spectral data smoothing using SNV and MSC


I am trying to filter the hyperspectral data. I have 204 spectral bands. I tried R for the standard normal variate (SNV) and multiple scattering correction (MSC) using the following codes. For SNV:

spectra <- data[, 1:204]
means <- apply(spectra, 2, mean)
sds <- apply(spectra, 2, sd)
data_snv <- scale(spectra, center = means, scale = sds)

For MSC:

average_spectrum <- apply(spectra, 2, mean)
corrected_spectra <- sweep(spectra, 2, average_spectrum, FUN = "-")

Want to confirm whether these are correct or not?

Tried using these codes but not sure.


Solution

  • You can use prospectr package to do all these like

    library(prospectr)
    
    snv_spc <- standardNormalVariate(X = spectra)
    msc_spc <- msc(X = spectra)