| gaussianSmooth2D | R Documentation |
Takes a matrix of numeric values and smooths it by convolution with a symmetric Gaussian window function. Values outside the matrix are either treated as zero, attenuating the edges, or assumed to continue beyond the edges.
gaussianSmooth2D(
m,
kernelSize = 5,
kernelSD = 0.5,
action = c("blur", "unblur"),
amount = 0.5,
padWith = c("repeat", "zero"),
plotKernel = FALSE
)
m |
input matrix (numeric, on any scale, doesn't have to be square) |
kernelSize |
vector of size 1 or 2: the size of the Gaussian kernel, in points (forced to odd values). kernelSize = 0 means no smoothing along that dimension. |
kernelSD |
the SD of the Gaussian kernel evaluated over [-1, 1]: for ex., if kernelSD = 0.5, the kernel spans approximately ±2 SDs |
action |
'blur' = kernel-weighted average, 'unblur' = unsharp masking |
amount |
the amount of residual to mix with the original when
unblurring: |
padWith |
how to treat the edges of the matrix: 'repeat' = the edge rows/columns are assumed to continue beyond the matrix; 'zero' = values outside the matrix are assumed to be zero, attenuating the smoothed edges |
plotKernel |
if TRUE, plots the kernel |
A numeric matrix of the same dimensions as input.
modulationSpectrum spectrogram
data('speechEx', package = 'soundgen')
s = spectrogram(speechEx, from = 0, to = 1, windowLength = 10,
output = 'original', plot = FALSE)
s = log(s + .001)
image(t(s))
s1 = gaussianSmooth2D(s, kernelSize = 5, plotKernel = TRUE)
image(t(s1))
# more smoothing in time than in frequency
s2 = gaussianSmooth2D(s, kernelSize = c(5, 15))
image(t(s2))
# vice versa - more smoothing in frequency
s3 = gaussianSmooth2D(s, kernelSize = c(25, 3))
image(t(s3))
# smoothing only in one dimension
s4 = gaussianSmooth2D(s, kernelSize = c(25, 0))
image(t(s4))
s5 = gaussianSmooth2D(s, kernelSize = c(0, 15))
image(t(s5))
# sharpen the image
s6 = gaussianSmooth2D(s, kernelSize = 5, action = 'unblur', amount = .5)
image(t(s6))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.