Learn R Programming

RnavGraph (version 0.1.8)

ng_image_array_gray: Convert a matrix or data.frame of image data into a NG_image object.

Description

NG_image objects are needed to plot images in the tk2d device.

ng_image_array_gray imports gray scale images that are saved in a matrix structure, that is every row or column contains the pixel data of an image.

See the "alpha_letter", "digits", "faces", "frey" and "umist_faces" demos (demo(package="RnavGraph")) for examples.

Usage

ng_image_array_gray(name, imageData, width, height, img_in_row = TRUE, invert = FALSE, rotate = 0)

Arguments

name
Character string.
imageData
data.frame of matrix with image data. Image information must be stored as a gray scale value (0-255) within a single row or column.
width
Pixel width of image.
height
Pixel height of image.
img_in_row
Logical. Single image stored in a row or column in imageData.
invert
For invert=FALSE 0 = whit, for invert=TRUE 0=black.
rotate
Rotate the image: 0, 90, 180 or 270 degree.

Value

NG_image object

See Also

navGraph, ng_image_files, ng_2d

Examples

Run this code
Img <- matrix(c(0,0,0,255,255,255,
                0,0,0,255,255,255,
                0,0,0,255,255,255,
                255,255,255,0,0,0,
                255,255,255,0,0,0,
                255,255,255,0,0,0),
              byrow = TRUE, ncol=6)

ng.img <- ng_image_array_gray("Test",
                cbind(as.vector(Img),as.vector(Img)),6,6,FALSE)
ng.img

## See demos and vignette

Run the code above in your browser using DataLab