https://github.com/cran/simecol
Tip revision: b6a788c979e27973358268bf4d95e2369868a4da authored by Thomas Petzoldt on 27 June 2009, 00:00:00 UTC
version 0.6-9
version 0.6-9
Tip revision: b6a788c
seedfill.Rd
\name{seedfill}
\alias{seedfill}
\title{Color Fill Algorithm}
\description{
Fills a bounded area within a numeric matrix with a given number (color).
}
\usage{
seedfill(z, x=1, y=1, fcol=0, bcol=1, tol=1e-6)
}
\arguments{
\item{z}{a matrix containing an image (double precision values are possible).}
\item{x, y}{start coordinates of the filled area.}
\item{fcol}{numeric value of the fill color.}
\item{bcol}{numeric value of the border value.}
\item{tol}{numeric value of border color tolerance.}
}
\seealso{
\code{\link{neighbours}}
}
\details{
The function implements a basic color fill algorithm for use in image
manipulation or cellular automata.
}
\value{
A matrix with the same structure as \code{z}.
}
\examples{
# define a matrix
z<-matrix(0, nrow=20, ncol=20)
# draw some lines
z[10,]<-z[,10] <- 1
z[5,] <-z[,5] <- 3
# plot matrix and filled variants
par(mfrow=c(2, 2))
image(z)
image(seedfill(z))
image(seedfill(z ,x=15, y=15, fcol=1, bcol=3))
image(seedfill(z, x=7, y=7, fcol=3, bcol=1))
}
\keyword{array}