\HeaderA{thresh}{Image and color channel thresholding}{thresh}
\aliasA{athresh}{thresh}{athresh}
\aliasA{athresh,Image-method}{thresh}{athresh,Image.Rdash.method}
\aliasA{cthresh}{thresh}{cthresh}
\aliasA{cthresh,Image-method}{thresh}{cthresh,Image.Rdash.method}
\aliasA{thresh,Image-method}{thresh}{thresh,Image.Rdash.method}
\keyword{manip}{thresh}
\begin{Description}\relax
Functions to threshold images and color channels of images.
\end{Description}
\begin{Usage}
\begin{verbatim}

  ## S4 method for signature 'Image':
  thresh(x, w=5, h=5, offset=0.01, ...)
  ## S4 method for signature 'Image':
  athresh(x, w=10, h=10, offset=0, ...)
  ## S4 method for signature 'Image':
  cthresh(x, threshold=0, ...)
  
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] An object of \code{\LinkA{Image}{Image.Rdash.class}}. For \code{thresh} it must be
in the \code{\LinkA{Grayscale}{Grayscale}} mode. 
\item[\code{w, h}] Thresholding frame width and height in pixel. 
\item[\code{offset}] Threshold offset from the mean value. 
\item[\code{threshold}] Threshold value for channel thresholding (uniform). 
\item[\code{...}] Reserved. 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If \code{thresh} and \code{athresh} are adaptive thresholind functions.
While \code{athresh} can be used on both \code{\LinkA{Grayscale}{Grayscale}} and 
\code{\LinkA{TrueColor}{TrueColor}} images, \code{thresh} can only be used on 
\code{Grayscale} images, however it is significantly faster on them.

The value of \code{offset} in \code{thresh} is on the same scale as data, i.e.
the default value is selected assuming data in the range \code{[0,1]}. This
value for \code{athresh} should be selected empirically, as this function
uses \code{AdaptiveThreshold} of \code{ImageMagick} and the scale of this
parameter was not documented; the reasonable values are usually in the orders
of 500, 1000 or avobe (at least to obtain similar thresholding to that of
0.01 with \code{thresh} on cytomicroscopic images. ).
\end{Details}
\begin{Value}
A new instance of \code{\LinkA{Image}{Image.Rdash.class}} in the same color mode as input.
\end{Value}
\begin{Author}\relax
Oleg Sklyar, \email{osklyar@ebi.ac.uk},  2005-2007
\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}, \LinkA{Image}{Image.Rdash.class}, 
  \LinkA{Image}{Image.Rdash.class}
}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## see example(watershed)
\end{ExampleCode}
\end{Examples}

