Learn R Programming

rayimage (version 0.2.3)

render_resized: Resize Image

Description

Resizes an image or a matrix, using bilinear interpolation.

Usage

render_resized(image, mag = 1, dims = NULL, filename = NULL, preview = FALSE)

Arguments

image

Image filename, 3-layer RGB array, or matrix.

mag

Default 1. Amount to magnify the image, preserving aspect ratio. Overridden if dim is not NULL.

dims

Default NULL. Exact resized dimensions.

filename

Default NULL. The filename of the image to be saved. If this is not given, the image will be plotted instead.

preview

Default FALSE. Whether to plot the convolved image, or just to return the values.

Value

3-layer RGB resized array or matrix.

Examples

Run this code
# NOT RUN {
#Plot the image with a title
# }
# NOT RUN {
dragon %>%
 add_title("Dragon", title_offset=c(10,10), title_bar_color="black",
           title_size=20, title_color = "white") %>%
 plot_image()
# }
# NOT RUN {
#Half of the resolution
# }
# NOT RUN {
render_resized(dragon, mag = 1/2) %>%
 add_title("Dragon (half res)", title_offset=c(5,5), title_bar_color="black",
           title_size=10, title_color = "white") %>%
 plot_image()
# }
# NOT RUN {
#Double the resolution
# }
# NOT RUN {
render_resized(dragon, mag = 2) %>%
 add_title("Dragon (2x res)", title_offset=c(20,20), title_bar_color="black",
           title_size=40, title_color = "white") %>%
 plot_image()
# }
# NOT RUN {
#Specify the exact resulting dimensions
# }
# NOT RUN {
render_resized(dragon, dim = c(320,160)) %>%
 add_title("Dragon (custom size)", title_offset=c(10,10), title_bar_color="black",
           title_size=20, title_color = "white") %>%
 plot_image()
# }

Run the code above in your browser using DataLab