ort: Create a data frame representation of an image

View source: R/o.R

ortR Documentation

Create a data frame representation of an image

Description

Takes a cimg object and attempts to create a data frame that, when plotted using the default plot in base R, looks like the original image.

Usage

ort(
  img,
  bg = 1,
  grid_size = function(x) {
     1/(250 * (1.0001 - x))
 },
  grid_offset = function(x) {
     sin(x * 100) * 10
 }
)

Arguments

img

An cimg object containing an image (from 'imager')

bg

Background color in case of alpha (default is white)

grid_size

Size of grid used for conversion

grid_offset

Offset of grid used for conversion

Value

A data frame with two columns, 'x' and 'y' that hopefully resembles the image when plotted

Examples

# Load image using imager
pineapple_img = load.image(system.file("FallingPineapple_16x16.png", package = "ort"))

# Convert to data frame plot
pineapple_ort = ort(pineapple_img)
plot(pineapple_ort)


# Example with alpha background
alph_img = load.image(system.file("alpha_gradient_test.png", package = "ort"))

# default assumes bg = 1 (white background)
alph_ort = ort(alph_img)
plot(alph_ort)

alph_ort_grey = ort(alph_img, bg = 0.5)
plot(alph_ort_grey)


ort documentation built on Feb. 23, 2026, 5:08 p.m.