The function integral
is generic, with methods
for spatial objects
("im"
, "msr"
, "linim"
, "linfun"
)
and one-dimensional functions ("density"
, "fv"
).
The method integral.im
treats the pixel image f
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 f
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)
.
If domain
is a window (class "owin"
) then the integration
will be restricted to this window. If domain
is a tessellation
(class "tess"
) then the integral of f
in each
tile of domain
will be computed.
If weight
is given, it should be a pixel image or a function of
coordinates \(x\) and \(y\) returning numerical values.
Then each pixel value of f
will be multiplied by the corresponding value of weight
.
Effectively, the result is the integral of weight * f
.