Filters an image using the fast 2D FFT convolution product.
Behaviour at image borders. The default is to wrap the image around borders. For other modes see details.
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
"circular" behaviour at boundaries is to wrap the image around borders.
"replicate" mode pixels outside the bounds of the image are assumed to equal the nearest border pixel value.
Numeric values of
boundary yield linear convolution by padding the image with the given value.
x contains multiple frames, the filter is applied separately to each frame.
Image object or an array, containing the filtered version
Andrzej Oleś, Gregoire Pau
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
x = readImage(system.file("images", "sample-color.png", package="EBImage")) display(x, title='Sample') ## Low-pass disc-shaped filter f = makeBrush(21, shape='disc', step=FALSE) display(f, title='Disc filter') f = f/sum(f) y = filter2(x, f) display(y, title='Filtered image') ## High-pass Laplacian filter la = matrix(1, nc=3, nr=3) la[2,2] = -8 y = filter2(x, la) display(y, title='Filtered image')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.