meanFilter {imagine} | R Documentation |
This functions take a matrix
object, and for each cell calculate
mean, median or certain quantile about a squared neighborhood by matrix of dimension
(radius*radius).
meanFilter(X, radius, times = 1) quantileFilter(X, radius, probs, times = 1, na = NA) medianFilter(X, radius, times = 1, na = NA)
X |
A |
radius |
Size of squared kernel to apply median. |
times |
How many times do you want to apply the filter? |
probs |
|
na |
|
Functions use C++ algorithms. More details are shown in the vignette.
A matrix
object with the same dimensions of X
.
quantileFilter
don't use a kernel but, for each cell, it returns
the position
of quantile 'probs' (value between 0 and 1).
medianFilter
is a wrapper of quantileFilter
with probs = 0.5.
# Generate example matrix nRows <- 50 nCols <- 100 myMatrix <- matrix(runif(nRows*nCols, 0, 100), nrow = nRows, ncol = nCols) radius <- 3 # Make convolution myOutput1 <- meanFilter(X = myMatrix, radius = radius) myOutput2 <- quantileFilter(X = myMatrix, radius = radius, probs = 0.1) myOutput3 <- medianFilter(X = myMatrix, radius = radius) # Plot results par(mfrow = c(2, 2)) image(myMatrix, zlim = c(0, 100), title = "Original") image(myOutput1, zlim = c(0, 100), title = "meanFilter") image(myOutput2, zlim = c(0, 100), title = "quantileFilter") image(myOutput3, zlim = c(0, 100), title = "medianFilter")