blur(x, sigma = NULL, ..., normalise=FALSE, bleed = TRUE, varcov=NULL)
"Smooth"(X, sigma = NULL, ..., normalise=FALSE, bleed = TRUE, varcov=NULL)
"im"
.sigma
.
x
.
x
. Smooth.im
is a method for the generic Smooth
for pixel images. It is currently identical to blur
,
apart from the name of the first argument.
The blurring kernel is the isotropic Gaussian kernel with standard
deviation sigma
, or the anisotropic Gaussian kernel with
variance-covariance matrix varcov
.
The arguments sigma
and varcov
are incompatible.
Also sigma
may be a vector of length 2 giving the
standard deviations of two independent Gaussian coordinates,
thus equivalent to varcov = diag(sigma^2)
.
If the pixel values of x
include some NA
values
(meaning that the image domain does not completely fill
the rectangular frame) then these NA
values are first reset to zero.
The algorithm then computes the convolution $x * G$
of the (zero-padded) pixel
image $x$ with the specified Gaussian kernel $G$.
If normalise=FALSE
, then this convolution $x * G$
is returned.
If normalise=TRUE
, then the convolution $x * G$
is normalised by
dividing it by the convolution $w * G$ of the image
domain w
with the same Gaussian kernel. Normalisation ensures that the result
can be interpreted as a weighted average of input pixel values,
without edge effects due to the shape of the domain.
If bleed=FALSE
, then pixel values outside the original image
domain are set to NA
. Thus the output is a pixel image with the
same domain as the input. If bleed=TRUE
, then no such
alteration is performed, and the result is a pixel image defined
everywhere in the rectangular frame containing the input image.
Computation is performed using the Fast Fourier Transform.
interp.im
for interpolating a pixel image to a finer resolution,
density.ppp
for blurring a point pattern,
Smooth.ppp
for interpolating marks attached to points.
data(letterR)
Z <- as.im(function(x,y) { 4 * x^2 + 3 * y }, letterR)
par(mfrow=c(1,3))
plot(Z)
plot(letterR, add=TRUE)
plot(blur(Z, 0.3, bleed=TRUE))
plot(letterR, add=TRUE)
plot(blur(Z, 0.3, bleed=FALSE))
plot(letterR, add=TRUE)
par(mfrow=c(1,1))
Run the code above in your browser using DataLab