smooth_speclib: Smooth spectra

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Smooth spectra using Savitzky-Golay filtering, lowess-, spline-functions or mean filter.

Usage

1
smoothSpeclib(x, method = "mean", ...)

Arguments

x

Object of class Speclib.

method

Character string giving the method to be used. Predefined valid options are "sgolay", "lowess", "spline" and "mean". However, method can also be the (character) name of any other filter function (see examples).

...

Further arguments passed to filter functions. See examples.

Details

This function allows filtering using four different methods:

Value

Object of class Speclib.

Author(s)

Lukas Lehnert

References

Tsai, F. & Philpot, W. (1998): Derivative analysis of hyperspectral data. Remote Sensing of Environment 66/1. 41-51.

See Also

sgolayfilt, lowess, spline, meanfilter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
data(spectral_data)

## Example of predefined filter functions
## Savitzky-Golay
sgolay <- smoothSpeclib(spectral_data, method="sgolay", n=25)

## Spline
spline <- smoothSpeclib(spectral_data, method="spline", 
                         n=round(nbands(spectral_data)/10,0))

## Lowess
lowess <- smoothSpeclib(spectral_data, method="lowess", f=.01)

## Mean
meanflt <- smoothSpeclib(spectral_data, method="mean", p=5)

par(mfrow=c(2,2))
plot(spectral_data, FUN=1, main="Savitzky-Golay")
plot(sgolay, FUN=1, new=FALSE, col="red", lty="dotted")
plot(spectral_data, FUN=1, main="Spline")
plot(spline, FUN=1, new=FALSE, col="red", lty="dotted")
plot(spectral_data, FUN=1, main="Lowess")
plot(lowess, FUN=1, new=FALSE, col="red", lty="dotted")
plot(spectral_data, FUN=1, main="Mean")
plot(meanflt, FUN=1, new=FALSE, col="red", lty="dotted")

## Example of a not predefined filter function (Butterworth filter)
bf <- butter(3, 0.1)
bf_spec <- smoothSpeclib(spectral_data, method="filter", filt=bf)
plot(spectral_data, FUN=1, main="Butterworth filter")
plot(bf_spec, FUN=1, new=FALSE, col="red", lty="dotted")

hsdar documentation built on Nov. 17, 2017, 4:35 a.m.