baseline | R Documentation |
Fits a baseline to each spectrum in a matrix and removes it from the corresponding input spectrum. A vector can also be passed to this function.
baseline(X, wav)
X |
a numeric matrix or vector to process (optionally a data frame that can be coerced to a numerical matrix). |
wav |
optional. A numeric vector of band positions. |
The baseline function find points lying on the convex hull of a spectrum, connects the points by linear interpolation and subtracts the interpolated line (baseline) from the corresponding spectrum.
a matrix or vector with the baselined spectra. The resulting matrix
is output with an attribute called baselines
which contain the spectra
of the fitted baselines.
This function is similar to continuumRemoval
and it might
replace some of its functionality in the future.
Leonardo Ramirez-Lopez with contributions from Mervin Manalili
savitzkyGolay
, movav
,
gapDer
, binning
, continuumRemoval
data(NIRsoil)
wav <- as.numeric(colnames(NIRsoil$spc))
# plot of the 5 first absorbance spectra
matplot(wav,
t(NIRsoil$spc[1:5, ]),
type = "l",
ylim = c(0, .6),
xlab = "Wavelength /nm",
ylab = "Absorbance"
)
bs <- baseline(NIRsoil$spc, wav)
matlines(wav, t(bs[1:5, ]))
fitted_baselines <- attr(bs, "baselines")
matlines(wav, t(fitted_baselines[1:5, ]))
title("Original spectra, baselines and baselined spectra")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.