View source: R/gaussianSmoothingSlope.R
gaussianSmoothingSlope | R Documentation |
Slope of a curve smoothed by a gaussian filter; this is a classical difference of gaussian filter (Gonzalez and Woods 2008) with the possibility to indicate specific output points.
gaussianSmoothingSlope(x,y,sd=1,xout=x,...)
x |
The x values formatted as a vector |
y |
The y values, formatted as a vector of length identical to the length of |
sd |
Standard deviation for the smoothing, in terms of x-coordinates |
xout |
The x values where an output is desired |
... |
Supplementary arguments to be passed to gaussianSmoothing, used internally |
A numerical vector of the same length as xout
, giving the estimated slope at each point given in xout
Thomas+Marina Braschler
Digital Image Processing, 3rd edition, Gonzalez R.C. and Woods R.E., Pearson, 2008, ISBN 9780133002324
# First, without boundary extension. In theory, the smoothened curve should rise linearly, and the slope be constant at 1/100 (=10 when multiplied with 1000) x=seq(from=0,to=1500,by=0.25) xout=x y=runif(length(x))+x/100 sd=50 smoothed=gaussianSmoothing(x=x,y=y,sd=sd,xout=xout) slope=gaussianSmoothingSlope(x=x,y=y,sd=sd,xout=xout) plot(x=x,y=y,type="p") plot.xy(xy.coords(x=xout,y=smoothed),type="l",col="red") plot.xy(xy.coords(x=xout,y=slope*1000),type="l",col="green") # In particular the slope in the above example nicely shows the edge problem. This can be first-order corrected with linear boundary extension: x=seq(from=0,to=1500,by=0.25) xout=x y=runif(length(x))+x/100 sd=50 boundary_extension=500 smoothed=gaussianSmoothing(x=x,y=y,sd=sd,xout=xout,boundary_extension=boundary_extension) slope=gaussianSmoothingSlope(x=x,y=y,sd=sd,xout=xout,boundary_extension=boundary_extension) plot(x=x,y=y,type="p") plot.xy(xy.coords(x=xout,y=smoothed),type="l",col="red") plot.xy(xy.coords(x=xout,y=slope*1000),type="l",col="green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.