smooth.2dbasis: Construct a 2d-functional data object by smoothing data.

Description Usage Arguments Value Examples

Description

Discrete observations on one image are fit with a set of smooth curves, each defined by an expansion in terms of user-selected basis functions. The fitting criterion is least squares.

Usage

1
smooth.2dbasis(s, u, y, e, f)

Arguments

s

a set of argument values corresponding to the observations in the rows of the matrix y.

u

a set of argument values corresponding to the observations in the columns of the matrix y.

y

the matrix of observed values corresponding s nad u.

e

a functional data basis object for the first argument s of the bivariate function.

f

a functional data basis object for the second argument t of the bivariate function.

Value

A 2d-functional object of class 'bifd'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
require(imager)
im <- as.cimg(function(x,y)
sin(x/16)+cos(y/16),128,128)
plot(im)
y <- im %>% as.matrix
m <- nrow(y)
n <- ncol(y)
p<-9
q<-9
e <- create.bspline.basis(c(0,1),p)
f <- create.bspline.basis(c(0,1),q)
u <- seq(0,1,length.out= n)
s <- seq(0,1,length.out= m)
x <- smooth.2dbasis(s,u,y,e,f)
y_hat <- eval.bifd(s,u,x)
sqrt(sum((y-y_hat)^2))
im_hat <- as.cimg(y_hat)
par(mfrow=c(1,2))
plot(im,main="True image")
plot(im_hat,main="Smoothed image")

haghbinh/fda2d documentation built on May 7, 2019, 6:58 p.m.