\HeaderA{filter2}{2D Convolution Filter}{filter2}
\aliasA{filter2,array,matrix-method}{filter2}{filter2,array,matrix.Rdash.method}
\aliasA{filter2,Image,matrix-method}{filter2}{filter2,Image,matrix.Rdash.method}
\aliasA{filter2-methods}{filter2}{filter2.Rdash.methods}
\aliasA{mkball}{filter2}{mkball}
\aliasA{mkbox}{filter2}{mkbox}
\begin{Description}\relax
2D convolution-based linear filter for images and matrix data.
\end{Description}
\begin{Usage}
\begin{verbatim}
  ## S4 method for signature 'Image, matrix':
  filter2(x, filter, ...)

  mkball(n, shape="step")
  mkbox(n)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] An object of \code{\LinkA{Image}{Image.Rdash.class}} in Grayscale mode, a numeric 
\code{array} or a \code{matrix}. 
\item[\code{filter}] A square \code{matrix} with odd dimensions.
\item[\code{n}] A positive integer of length 1, specifying the size (number
of rows and columns) of the returned square matrix.
\item[\code{shape}] A character vector of length 1, with one of two values:
\code{step} for a step function, \code{ball} for a semisphere.
\item[\code{...}] Further arguments.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The convolution filter is based on \code{fft} transforms.
If \code{x} is an \code{array}, the filter is applied per frame (as to images).
\end{Details}
\begin{Value}
\code{filter2} returns a transformed object of the same class as 
\code{x}.

\code{mkball} and \code{mkbox} return a square matrix that can be used
for the \code{filter} argument of \code{filter2}. Its dimensions
(number of rows and columns) are given by \code{n}. For
\code{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 
\code{n/2} around the center element of the matrix.
For \code{shape="ball"}, the non-zero elements of
the matrix are \code{z = sqrt(radius\textasciicircum{}2 - x\textasciicircum{}2 - y\textasciicircum{}2)}, a
parameterization of a semisphere.
\end{Value}
\begin{Author}\relax
Gregoire Pau, \email{gpau@ebi.ac.uk}
\end{Author}
\begin{SeeAlso}\relax
\code{
    \LinkA{Image}{Image.Rdash.class}, \LinkA{Image}{Image.Rdash.class}
  }
\end{SeeAlso}

