| filter2 {EBImage} | R Documentation |
Filters an image using the fast 2D FFT convolution product.
filter2(x, filter)
x |
An Image object or an array. |
filter |
An Image object or an array, with odd spatial
dimensions. Must contain only one frame. |
Linear filtering is useful to perform low-pass filtering (to blur
images, remove noise...) and high-pass filtering (to detect
edges, sharpen images). The function makeBrush is useful to
generate filters.
Data is reflected around borders.
If x contains multiple franes, the filter will be applied one each frame.
An Image object or an array, containing the filtered version
of x.
Gregoire Pau, gpau@ebi.ac.uk
makeBrush, convolve, fft, blur
x = readImage(system.file("images", "lena-color.png", package="EBImage"))
if (interactive()) display(x, title='Lena')
## Low-pass disc-shaped filter
f = makeBrush(21, shape='disc', step=FALSE)
if (interactive()) display(f, title='Disc filter')
f = f/sum(f)
y = filter2(x, f)
if (interactive()) display(y, title='Filtered lena')
## High-pass Laplacian filter
la = matrix(1, nc=3, nr=3)
la[2,2] = -8
y = filter2(x, la)
if (interactive()) display(y, title='Filtered lena')