
These are alternatives to
EBImage::filter2()
and EBImage::medianFilter()
for
smooth and median filtering respectively. These functions have many options
for dealing with NA
values which EBImage
's functions lack.
median_filter(mat, size = 1L, na_rm = FALSE, na_count = FALSE)smooth_filter(mat, size = 1L, na_rm = FALSE, na_count = FALSE)
A matrix (representing an image).
An integer; the median filter radius.
Should NA
s be ignored?
If this is TRUE, in each median calculation, if the majority
of arguments are NA
s, NA
is returned but if the NA
s are
in the minority, they are ignored as in median(x, na.rm = TRUE)
.
A matrix (the median filtered image).
The behavior at image boundaries is such as the source image has been padded with pixels whose values equal the nearest border pixel value.
# NOT RUN {
m <- matrix(1:9, nrow = 3)
m[2:3, 2:3] <- NA
print(m)
median_filter(m)
median_filter(m, na_rm = TRUE)
median_filter(m, na_count = TRUE)
smooth_filter(m)
smooth_filter(m, na_rm = TRUE)
smooth_filter(m, na_count = TRUE)
# }
Run the code above in your browser using DataLab