\HeaderA{floodFill}{Region filling}{floodFill}
\begin{Description}\relax
Fill regions in images.
\end{Description}
\begin{Usage}
\begin{verbatim}
  floodFill(x, pt, col, tolerance=0)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] An \code{Image} object or an array.
\item[\code{pt}] Coordinates of the start filling point.
\item[\code{col}] Fill color. This argument should be a numeric for Grayscale images
and an R color for Color images.
\item[\code{tolerance}] Color tolerance used during the fill.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Flood fill is performed using the fast scan line algorithm. Filling
starts at \code{pt} and grows in connected areas where the absolute
difference of the pixels intensities (or colors) remains below
\code{tolerance}.
\end{Details}
\begin{Value}
An \code{Image} object or an array, containing the transformed version
of \code{x}.
\end{Value}
\begin{Author}\relax
Gregoire Pau, Oleg Sklyar; 2007
\end{Author}
\begin{Examples}
\begin{ExampleCode}
  x = readImage(system.file("images", "shapes.png", package="EBImage"))
  y = floodFill(x, c(67, 146), 0.5)
  if (interactive()) display(y)

  y = channel(y, 'rgb')
  y = floodFill(y, c(48, 78), 'red')
  y = floodFill(y, c(156, 52), 'orange')        
  if (interactive()) display(y)

  x = readImage(system.file("images", "lena.gif", package="EBImage"))
  y = floodFill(x, c(226, 121), 1, tolerance=0.1)
  if (interactive()) display(y)
\end{ExampleCode}
\end{Examples}

