| integral.im {spatstat} | R Documentation |
Computes the integral of a pixel image.
integral.im(x, ...)
x |
A pixel image (object of class |
... |
Ignored. |
This function treats the pixel image x as a function of
the spatial coordinates, and computes its integral.
The integral is calculated
by summing the pixel values and multiplying by the area of one pixel.
The pixel values of x may be numeric, integer, logical or
complex. They cannot be factor or character values.
The logical values TRUE and FALSE are converted to
1 and 0 respectively, so that the integral of a logical
image is the total area of the TRUE pixels, in the same units
as unitname(x).
For more complicated integration tasks such as computing the integral
of an image over a specified subset, use eval.im to
construct an integrand or [.im to extract a subset of
the image.
A single numeric or complex value.
Adrian Baddeley Adrian.Baddeley@uwa.edu.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner r.turner@auckland.ac.nz
# approximate integral of f(x,y) dx dy
f <- function(x,y){3*x^2 + 2*y}
Z <- as.im(f, square(1))
integral.im(Z)
# correct answer is 2
data(cells)
D <- density(cells)
integral.im(D)
# should be approximately equal to number of points = 42
# integrate over the subset [0.1,0.9] x [0.2,0.8]
W <- owin(c(0.1,0.9), c(0.2,0.8))
DW <- D[W, drop=FALSE]
integral.im(DW)