## S3 method for class 'im':
by(data, INDICES, FUN, ...)
"im"
)."tess"
) or
a factor-valued pixel image.data
.FUN
.FUN
.by
for
pixel images (class "im"
). The pixel image data
is first divided into sub-images according
to INDICES
. Then the function FUN
is applied to each subset.
The results of each computation are returned in a list.
The grouping variable INDICES
may be either
"tess"
). Each tile of
the tessellation delineates a subset of the spatial domain."im"
) with factor
values. The levels of the factor determine subsets of the spatial
domain.split.im
,
tess
,
im
W <- square(1)
X <- as.im(function(x,y){sqrt(x^2+y^2)}, W)
Y <- dirichlet(runifpoint(12, W))
# mean pixel value in each subset
unlist(by(X, Y, mean))
# trimmed mean
unlist(by(X, Y, mean, trim=0.05))
Run the code above in your browser using DataLab