median_filter: Smooth and median filters with options for handling NAs.

Description Usage Arguments Details Value Examples

View source: R/RcppExports.R

Description

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.

Usage

1
2
3
median_filter(mat, size = 1L, na_rm = FALSE, na_count = FALSE)

smooth_filter(mat, size = 1L, na_rm = FALSE, na_count = FALSE)

Arguments

mat

A matrix (representing an image).

size

An integer; the median filter radius.

na_rm

Should NAs be ignored?

na_count

If this is TRUE, in each median calculation, if the majority of arguments are NAs, NA is returned but if the NAs are in the minority, they are ignored as in median(x, na.rm = TRUE).

Details

The behavior at image boundaries is such as the source image has been padded with pixels whose values equal the nearest border pixel value.

Value

A matrix (the median filtered image).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

nandb documentation built on May 17, 2021, 1:09 a.m.