Learn R Programming

imager (version 0.14)

pixel.grid: Returns the pixel grid for an image

Description

The pixel grid for image im gives the (x,y,z,c) coordinates of each successive pixel as a data.frame. The c coordinate has been renamed 'cc' to avoid conflicts with R's c function. NB: coordinates start at (x=1,y=1), corresponding to the top left corner of the image, unless standardise == TRUE, in which case we use the usual Cartesian coordinates with origin at the center of the image and scaled such that x varies between -.5 and .5, and a y arrow pointing up

Usage

pixel.grid(im, standardise = FALSE, drop.unused = TRUE)

Arguments

im
an image
standardise
If TRUE use a centered, scaled coordinate system. If FALSE use standard image coordinates (default FALSE)
drop.unused
if TRUE ignore empty dimensions, if FALSE include them anyway (default TRUE)

Value

  • a data.frame

Examples

Run this code
im <- as.cimg(array(0,c(10,10))) #A 10x10 image
pixel.grid(im) %>% head
pixel.grid(im,standardise=TRUE) %>% head
pixel.grid(im,drop.unused=FALSE) %>% head

Run the code above in your browser using DataLab