Description Usage Arguments Value Examples
Add transparency (set pixels to zero) area to image
1 |
img |
image object ( |
area |
area to modify: To invert the area (trim right to left or bottom to top), set
To modify from |
quiet |
boolean flag to hide messages of work area |
modified image object (cimg
class)
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 | ## Not run:
# Create test image
red <- matrix(0, 50, 50)
red[1:25, 1:25] <- 1
blue <- matrix(0, 50, 50)
blue[26:50, 1:25] <- 1
green <- matrix(0, 50, 50)
green[1:25, 26:50] <- 1
alpha <- matrix(1, 50, 50)
alpha[26:50, 26:50] <- 0
img <- imager::as.cimg(abind::abind(imager::as.cimg(red),
imager::as.cimg(blue),
imager::as.cimg(green),
imager::as.cimg(alpha),
along = 4))
# Remove red portion of the image
plot(add_alpha(img, c(1, 25, 1, 25)))
# Remove red and green portions
plot(add_alpha(img, c(1, -1, 1, 25)))
# Remove red and blue portions
plot(add_alpha(img, c(1, 25, 1, -1)))
# Remove green and alpha portions
plot(add_alpha(img, c(-1, 25, 1, -1)))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.