Skip to contents

image creates or coerces objects into a memory-optimized image S3 object in pliman. Storing pixel data efficiently (using 8-bit raw vectors by default) provides up to 8x memory reduction compared to standard float64 double arrays.

Usage

image(
  data = raw(),
  colormode = NULL,
  colspace = "RGB",
  gamma = 1,
  storage = c("raw", "double", "integer", "logical"),
  ...
)

as_image(
  data,
  colormode = NULL,
  colspace = "RGB",
  gamma = 1,
  storage = c("raw", "double", "integer", "logical"),
  dim = NULL,
  ...
)

is_image(x)

Arguments

data

An array, matrix, raw vector, or existing image object.

colormode

Character specifying color mode: "Color" (default for 3D arrays) or "Grayscale" (default for 2D matrices).

colspace

Character specifying color space (default "RGB").

gamma

Numeric gamma value (default 1.0).

storage

Character specifying storage type: "raw" (uint8 0..255, memory optimized) or "double" (0..1 floating point).

...

Additional arguments.

dim

Optional dimensions vector to reshape data.

x

An object to check if it inherits from class image.

Value

An S3 object of class c("image", "array").

Examples

if (FALSE) { # interactive()
img <- image(array(as.raw(sample(0:255, 300, replace = TRUE)), dim = c(10, 10, 3)))
print(img)
summary(img)
is_image(img)
}