If a mask is specified, setTo sets the color of the
parts of an image corresponding to the white parts of the mask to the desired
color. If no mask is specified, the entire image is set to the desired color.
Arguments
- image
An
Imageobject.- mask
An 8U, single-channel
Imageobject. The region to be colored should be non-zero.- color
A value or vector of any kind of R color specification compatible with
col2bgrrepresenting the color of each rectangle's outline (default: "red").- target
The location where the results should be stored. It can take 2 values:
- "new":
a new
Imageobject is created and the results are stored inside (the default).- "self":
the results are stored back into
image(faster but destructive).
- in_place
Deprecated. Use
targetinstead.
Value
If target="new", the function returns an Image
object. If target="self", the function returns nothing and modifies
image in place.
Author
Simon Garnier, garnier@njit.edu
Examples
balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
mask <- zeros(nrow(balloon), ncol(balloon), 1)
poly <- data.frame(x = c(290, 290, 440, 440), y = c(170, 325, 325, 170))
fillPoly(mask, poly, color = "white")
#> NULL
balloon_painted <- setTo(balloon, mask, "green")