Learn R Programming

videoplayR (version 0.3.1)

r2img: Convert a matrix or an array to a vpImage object

Description

This function converts a 2D matrix or a 3D array to a vpImage object to that can be manipulated using the videoplayR image and video manipulation toolbox. Binary matrices will be converted to binary vpImage objects. Integer matrices with values in [0, 255] will be converted to grayscale vpImage objects. Numeric matrics will be converted to 2D numeric vpImage objects. 3D integer arrays with values in [0, 255] will be converted to RGB vpImage objects. 3D numeri arrays will be converted to 3D numeric vpImage objects.

Usage

r2img(array, numeric = FALSE)

Arguments

array
The matrix or array to convert.
numeric
A logical value indicating if the matrix or array should be treated as a numeric object. If FALSE (default), the matrix or array will be casted to an integer matrix or array. If TRUE, the matrix or array will be converted to a numeric vpImage object.

Value

This function returns a vpImage object.

See Also

img2r, vpImage

Examples

Run this code
gradient <- function(x1, x2) { x1 + x2 }
x <- 0:127
mat <- gradient(outer(rep(1, length(x)), x), x)
img <- r2img(mat)
imshow(img)

Run the code above in your browser using DataLab