# NOT RUN {
data(demopat)
# window object
W <- Window(demopat)
plot(W)
Z <- as.im(W)
image(Z)
# function
Z <- as.im(function(x,y) {x^2 + y^2}, unit.square())
image(Z)
# function with extra arguments
f <- function(x, y, x0, y0) {
sqrt((x - x0)^2 + (y-y0)^2)
}
Z <- as.im(f, unit.square(), x0=0.5, y0=0.5)
image(Z)
# Revisit the Sixties
data(letterR)
Z <- as.im(f, letterR, x0=2.5, y0=2)
image(Z)
# usual convention in S
stuff <- list(x=1:10, y=1:10, z=matrix(1:100, nrow=10))
Z <- as.im(stuff)
# convert to finer grid
Z <- as.im(Z, dimyx=256)
#' distance functions
d <- distfun(redwood)
Zapprox <- as.im(d)
Zexact <- as.im(d, approx=FALSE)
plot(solist(approx=Zapprox, exact=Zexact), main="")
# pixellate the Dirichlet tessellation
Di <- dirichlet(runifpoint(10))
plot(as.im(Di))
plot(Di, add=TRUE)
# as.im.data.frame is the reverse of as.data.frame.im
grad <- bei.extra$grad
slopedata <- as.data.frame(grad)
slope <- as.im(slopedata)
unitname(grad) <- unitname(slope) <- unitname(grad) # for compatibility
all.equal(slope, grad) # TRUE
# }
Run the code above in your browser using DataCamp Workspace