setTo | R Documentation |
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.
setTo(image, mask, color = "red", target = "new", in_place = NULL)
image |
An |
mask |
An 8U, single-channel |
color |
A value or vector of any kind of R color specification compatible
with |
target |
The location where the results should be stored. It can take 2 values:
|
in_place |
Deprecated. Use |
If target="new"
, the function returns an Image
object. If target="self"
, the function returns nothing and modifies
image
in place.
Simon Garnier, garnier@njit.edu
Image
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")
balloon_painted <- setTo(balloon, mask, "green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.