Description Usage Arguments Details Value Author(s) Examples
Fill regions in images.
1 |
x |
An |
pts |
Coordinates of the start filling points given as either of the following: a vector of the form |
col |
Fill color. This argument should be a numeric for Grayscale images and an R color for Color images. Values are recycled such that their length matches the number of points in |
tolerance |
Color tolerance used during the fill. |
Flood fill is performed using the fast scan line algorithm. Filling
starts at pts
and grows in connected areas where the absolute
difference of the pixels intensities (or colors) remains below
tolerance
.
An Image
object or an array, containing the transformed version
of x
.
Gregoire Pau, Oleg Sklyar; 2007
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | x = readImage(system.file("images", "shapes.png", package="EBImage"))
## fill a shape with 50% shade of gray
y = floodFill(x, c(67, 146), 0.5)
display(y)
## fill with color
y = toRGB(y)
y = floodFill(y, c(48, 78), 'orange')
display(y)
## fill multiple shapes with different colors
y = y[110:512,1:130,]
points = rbind(c(50, 50), c(100, 50), c(150, 50))
colors = c("red", "green", "blue")
y = floodFill(y, points, colors)
display(y)
## area fill
x = readImage(system.file("images", "sample.png", package="EBImage"))
y = floodFill(x, rbind(c(200, 400), c(200, 325)), 1, tolerance=0.1)
display(y)
## application to image stacks
f = system.file("images", "nuclei.tif", package="EBImage")
x = readImage(f)[1:250,1:250,]
x = opening(thresh(x, 12, 12), makeBrush(5, shape='disc'))
xy = lapply(getFrames(bwlabel(x)), function(x) computeFeatures.moment(x)[,1:2])
y = floodFill(toRGB(x), xy, c("red", "green", "blue"))
display(y)
|
Warning messages:
1: In matrix(pt, nrow = n, ncol = 2L, byrow = TRUE) :
data length [172] is not a sub-multiple or multiple of the number of rows [12]
2: In matrix(col, nrow = n, ncol = 1L) :
data length [9] is not a sub-multiple or multiple of the number of rows [12]
Only the first frame of the image stack is displayed.
To display all frames use 'all = TRUE'.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.