\HeaderA{closing}{Morphological operations on images}{closing}
\aliasA{closing,Image-method}{closing}{closing,Image.Rdash.method}
\aliasA{dilate}{closing}{dilate}
\aliasA{dilate,Image-method}{closing}{dilate,Image.Rdash.method}
\aliasA{erode}{closing}{erode}
\aliasA{erode,Image-method}{closing}{erode,Image.Rdash.method}
\aliasA{morphKern}{closing}{morphKern}
\aliasA{opening}{closing}{opening}
\aliasA{opening,Image-method}{closing}{opening,Image.Rdash.method}
\keyword{manip}{closing}
\begin{Description}\relax
Functions to perform morphological operations on binary images.
\end{Description}
\begin{Usage}
\begin{verbatim}
  
  ## S4 method for signature 'Image':
  dilate(x, kern=morphKern(5), iter=1, ...)
  ## S4 method for signature 'Image':
  erode(x, kern=morphKern(5), iter=1, ...)
  ## S4 method for signature 'Image':
  opening(x, kern=morphKern(5), iter=1, ...)
  ## S4 method for signature 'Image':
  closing(x, kern=morphKern(5), iter=1, ...)

  morphKern(size=5, shape="round")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] An object of \code{\LinkA{Image}{Image.Rdash.class}}. \code{x} should
be a binary image in the \code{\LinkA{Grayscale}{Grayscale}} mode. If image is
not binary, all non-zero pixels will be considered as 1 to turn the image
into a binary \code{\{0,1\}} image. 
\item[\code{kern}] Kernel mask matrix. 
\item[\code{iter}] Number of iterations. 
\item[\code{size, shape}] Kernel matrix size and shape. 
\item[\code{...}] Reserved. 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{morphKern} can be used to generate a kernel matrix for the use with any
of the morphological operators. The function can generate round and square 
kernels of odd size, e.g. 5, 7, 9 etc. Even sizes are not supported because
the location of the centre pixel is undefined. Kernels can be altered in any
desired way, this is just a convenience function.

\code{erode} applies the mask positioning its centre over every background pixel 
(0), every pixel which is not covered by the mask is reset to foreground (1).
In this way image features grow in size.

\code{dilate} applies the mask positioning its centre over every foreground pixel
(1), every pixel which is not covered by the mask is reset to background (0).
In this way image features seem shrink in size.

\code{opening} is erosion followed by dilation and \code{closing} is dilation
followed by erosion.
\end{Details}
\begin{Value}
A transformed image in an object of \code{\LinkA{Image}{Image.Rdash.class}}.

\code{morphKern} returns a square matrix of 0 and 1 of a given size.
\end{Value}
\begin{Author}\relax
Oleg Sklyar, \email{osklyar@ebi.ac.uk}, 2006
\end{Author}
\begin{References}\relax
\emph{ImageMagick}: \url{http://www.imagemagick.org}.
\end{References}
\begin{SeeAlso}\relax
\code{
    \LinkA{Image}{Image.Rdash.class}, \LinkA{Image}{Image.Rdash.class}, \LinkA{Image}{Image.Rdash.class}
}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## see example(propagate)
\end{ExampleCode}
\end{Examples}

