https://github.com/cran/simecol
Raw File
Tip revision: 1e19d2edb4e3509bc0e783acdb6f3a936aaac510 authored by Thomas Petzoldt on 29 June 2006, 00:00:00 UTC
version 0.3-10
Tip revision: 1e19d2e
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}
  \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}
back to top