filter2 {EBImage} | R Documentation

## 2D Convolution Filter

### Description

2D convolution-based linear filter for images and matrix data.

### Usage

      ## S4 method for signature 'Image, matrix':
      filter2(x, filter, ...)

      mkball(n, shape="step")
      mkbox(n)

### Arguments

`x` | An object of `Image` in Grayscale mode, a numeric `array` or a `matrix`.
`filter` | A square `matrix` with odd dimensions.
`n` | A positive integer of length 1, specifying the size (number of rows and columns) of the returned square matrix.
`shape` | A character vector of length 1, with one of two values: `step` for a step function, `ball` for a semisphere.
`...` | Further arguments.

### Details

The convolution filter is based on `fft` transforms. If `x` is an `array`, the filter is applied per frame (as to images).

### Value

`filter2` returns a transformed object of the same class as `x`.
`mkball` and `mkbox` return a square matrix that can be used for the `filter` argument of `filter2`. Its dimensions (number of rows and columns) are given by `n`. For `shape="step"`, the entries of the matrix are the integers 0 and 1, and the 1s correspond to the interior of a circle of radius `n/2` around the center element of the matrix. For `shape="ball"`, the non-zero elements of the matrix are `z = sqrt(radius^2 - x^2 - y^2)`, a parameterization of a semisphere.

### Author(s)

Gregoire Pau, gpau@ebi.ac.uk

### See Also

`Image, fft`

[Package EBImage version 2.6.0 Index]