Takes an RGB array/filename and adds an image overlay.

render_image_overlay(
  image,
  image_overlay = NULL,
  rescale_original = FALSE,
  alpha = NA,
  filename = NULL,
  preview = FALSE
)

Arguments

image

3-layer RGB/4-layer RGBA array, rayimg class, or filename of an image.

image_overlay

Default NULL. 3-layer RGB/4-layer RGBA array, rayimg class, or filename of an image. This image will be resized to the dimension of the image if it does not match exactly.

rescale_original

Default FALSE. If TRUE, function will resize the original image to match the overlay.

alpha

Default NA, using overlay's alpha channel. Otherwise, this sets the alpha transparency by multiplying the existing alpha channel by this value (between 0 and 1).

filename

Default NULL. File to save the image to. If NULL and preview = FALSE, returns an RGB array.

preview

Default FALSE. If TRUE, it will display the image in addition to returning it.

Value

A rayimg RGBA array.

Examples

if(run_documentation()){
#Plot the dragon
plot_image(dragon)
}

if(run_documentation()){
#Add an overlay of a red semi-transparent circle:
circlemat = generate_2d_disk(min(dim(dragon)[1:2]))
circlemat = circlemat/max(circlemat)

#Create RGBA image, with a transparency of 0.5
rgba_array = array(1, dim=c(nrow(circlemat),ncol(circlemat),4))
rgba_array[,,1] = circlemat
rgba_array[,,2] = 0
rgba_array[,,3] = 0
dragon_clipped = dragon
dragon_clipped[dragon_clipped > 1] = 1
render_image_overlay(dragon_clipped, image_overlay = rgba_array,
                 alpha=0.5, preview = TRUE)
}