ray_read_image: Read Image

View source: R/ray_read_image.R

ray_read_imageR Documentation

Read Image

Description

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

Usage

ray_read_image(image, convert_to_array = TRUE, preview = FALSE, ...)

Arguments

image

Image filename or 3-layer RGB array.

convert_to_array

Default TRUE. Whether to convert 2D B&W images/matrices to RGBA arrays.

preview

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

...

Arguments to pass to either jpeg::readJPEG, png::readPNG, or tiff::readTIFF.

Value

3-layer RGB array of the processed image.

Examples

if(run_documentation()){
#Write as a png
tmparr = tempfile(fileext=".png")
ray_read_image(dragon) |>
 ray_write_image(tmparr)
ray_read_image(tmparr) |>
 plot_image()
}
if(run_documentation()){
#Write as a JPEG (passing quality arguments via ...)
tmparr = tempfile(fileext=".jpg")
ray_read_image(dragon) |>
 ray_write_image(tmparr, quality = 0.2)
ray_read_image(tmparr) |>
 plot_image()
}
if(run_documentation()){
#Write as a tiff
tmparr = tempfile(fileext=".tiff")
ray_read_image(dragon) |>
 ray_write_image(tmparr)
ray_read_image(tmparr) |>
  plot_image()
}

rayimage documentation built on Sept. 11, 2024, 8:13 p.m.