filter2 {EBImage}R Documentation

2D Convolution Filter

Description

Filters an image using the fast 2D FFT convolution product.

Usage

  filter2(x, filter)

Arguments

x

An Image object or an array.

filter

An Image object or an array, with odd spatial dimensions. Must contain only one frame.

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 generate filters.

Data is reflected around borders.

If x contains multiple franes, the filter will be applied one each frame.

Value

An Image object or an array, containing the filtered version of x.

Author(s)

Gregoire Pau, gpau@ebi.ac.uk

See Also

makeBrush, convolve, fft, blur

Examples

  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')

[Package EBImage version 3.10.0 Index]