blur {tdarec} | R Documentation |
Gaussian blur of an array
Description
This function takes a numeric array of any dimension as input and returns a blurred array of the same dimensions as output.
Usage
blur(
x,
xmin = 0,
xmax = 2^ceiling(log(max(x + 1), 2)) - 1,
sigma = max(dim(x))/2^(length(dim(x)) + 1)
)
Arguments
x |
a numerical 'array' (including 'matrix') |
xmin |
the smallest possible value in |
xmax |
the largest possible value in |
sigma |
the standard deviation of the gaussian distribution with which
to convolve |
Details
This function is adapted from spatstat.explore::blur()
, part of
the spatstat package collection.
The procedure takes the following steps:
Rescale the value range from
[\code{xmin},\code{xmax}]
to[0,1]
.Convolve
x
withN(0,\code{sigma}^2)
.Rescale the result back to the original value range.
Value
An array of the same dimensions as x
.
Examples
square <- matrix(byrow = TRUE, nrow = 6L, c(
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 0, 0, 0,
0, 1, 0, 0, 1, 1, 1, 0,
0, 1, 0, 0, 1, 0, 1, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0
))
square_blur <- blur(square)
image(t(square))
image(t(square_blur))