10_raster_images: Raster Objects

Description Usage Arguments Value Examples

Description

Objects representing raster image data.

The class RImage has two subclasses SImage (for single channel images) and MImage (for multiple channel images).

Currently, pixel values (im) need to be between zero and one.

NOTE:
INTERNAL STRUCTURE OF OBJECTS IS SUBJECT TO CHANGE.
DO NOT USE SLOTS, DIRECTLY.

NOTE:
USING NON-sRGB COLOR SPACES REQUIRES THE colorspace PACKAGE TO BE INSTALLED AND LOADED.

Also, note that there's also a VImage object, which uses vector graphics.

Usage

1
2
3
4
as.SImage (im)
as.MImage (im, ..., input="sRGB", storage=input)

get.channel (im, which, ..., as.matrix=FALSE)

Arguments

im

For SImage:
A matrix or raster object.

For MImage:
A matrix, an array, a list, a SImage object or a raster object.
Arrays can have two or three dimensions.
In the 3d case, the last dimension can have 1 to 4 items, each representing a channel.
Lists can have 1 to 4 equally-sized matrices, each representing one channel.

For get.channel:
An MImage object.

input, storage

Single characters, giving the name of a valid color space from the colorspace package.
Refer to mapcol.
The input argument is ignored, unless the input is a three or four channel 3D array.

Input is the input color space, and storage is the storage color space.

Note that the colorspace package needs to be installed to use non-sRGB colorspaces.
Also, note that the same name is used for three channel images, and four channel images (with an alpha channel).
i.e. "sRGB" can be used for sRGB and sRGB-A.

which

Integer, which channel.

as.matrix

Logical, if false (default), return an SImage object, If true, return a matrix.

...

Ignored.

Value

An SImage, MImage or matrix object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library (png)

#adapted from png package
im0 <- readPNG (system.file ("img", "Rlogo.png", package="png") )

#multichannel image
im <- as.MImage (im0)

plot (im)

headt (as.raster (im) )

vectools documentation built on June 7, 2021, 9:08 a.m.