floodFill | R Documentation |
floodFill
fills a connected component starting from a
seed point with a specified color.
floodFill(
image,
seed = c(1, 1),
color = "white",
lo_diff = 0,
up_diff = 0,
connectivity = 4
)
image |
An |
seed |
A 2-element vector indicating the x and y coordinates of the seed point from where to start the filling. |
color |
A value or vector of any kind of R color specification
compatible with |
lo_diff |
Maximal lower brightness/color difference between the
currently observed pixel and one of its neighbors belonging to the component,
or a seed pixel being added to the component (see Details). It can be a
single value or a vector of the same length as the number |
up_diff |
Maximal upper brightness/color difference between the
currently observed pixel and one of its neighbors belonging to the component,
or a seed pixel being added to the component (see Details). It can be a
single value or a vector of the same length as the number |
connectivity |
The connetivity neighborhood to decide whether 2 pixels are contiguous. This parameter can take two values:
|
The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at (x,y) is considered to belong to the repainted domain if:
in case of a floating range:
image[x',y'] - lo_diff <= image[x,y] <= image[x',y'] + up_diff
in case of a fixed range:
image[seed$x,seed$y] − lo_diff <= image[x,y] <= image(seed$x,seed$y) + up_diff
where image[x′,y′] is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:
Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
Color/brightness of the seed point in case of a fixed range.
This function returns the number of pixels that were filled and
modifies image
in place.
Simon Garnier, garnier@njit.edu
connectedComponents
dots <- image(system.file("sample_img/dots.jpg", package = "Rvision"))
floodFill(dots, color = "green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.