detrend {prospectr} | R Documentation |
Normalizes each row of an input data.frame
or
matrix
by applying a SNV transformation followed by
fitting a second order linear model and returning the
fitted residuals.
detrend(X,wav)
X |
numeric |
wav |
wavelengths/ band centers |
The detrend is a row-wise transformation that allows to correct for wavelength-dependent scattering effects (variations in curvilinearity). A second-degree polynomial is fit through each spectrum:
x_i = aλ^2 + bλ + c + e_i
were x_i is the spectrum, λ is the wavelength vector, a, b, c are estimated by least square, and e_i are the residuals of the least square fit. Then, a detrend spectrum corresponds to:
x\ast_i = x_i - (aλ^2 + bλ + c = e_i)
a matrix
or vector
with detrend values
Antoine Stevens
Barnes RJ, Dhanoa MS, Lister SJ. 1989. Standard normal variate transformation and de-trending of near-infrared diffuse reflectance spectra. Applied spectroscopy, 43(5): 772-777.
standardNormalVariate
,
blockScale
, blockNorm
data(NIRsoil) wav <- as.numeric(colnames(NIRsoil$spc)) spc <- 1/10^NIRsoil$spc # conversion to reflectance opar <- par(no.readonly = TRUE) par(mfrow=c(2,1),mar=c(4,4,2,2)) matplot(wav,t(spc[1:10,]),type='l',xlab='',ylab='Reflectance') # plot of the 10 first spectra mtext('Raw spectra') det <- detrend(spc,wav) matplot(wav,t(det[1:10,]),type='l',xlab='Wavelength /nm',ylab='Reflectance') mtext('Detrend spectra') par(opar)