img_conversion: Convert images between class rimg and cimg or magick-image

img_conversionR Documentation

Convert images between class rimg and cimg or magick-image

Description

Conveniently convert single objects of class rimg to class cimg (from the package imager) or magick-image (from the package magick), both of which contains a suite of useful image-processing capabilities.

Usage

rimg2cimg(image)

rimg2magick(image)

Arguments

image

an object of class rimg

Value

an image of the specified class

Note

Attributes (e.g. scales, color-classes) will not be preserved following conversion from class rimg, so it's best to use early in the analysis workflow.

Author(s)

Thomas E. White thomas.white026@gmail.com

Hugo Gruson hugo.gruson+R@normalesup.org

Examples

papilio <- getimg(system.file("testdata/images/butterflies/papilio.png", package = "pavo"))

# Convert from class rimg to cimg
if (requireNamespace("imager", quiety = TRUE)) {
  papilio_cimg <- rimg2cimg(papilio)
  class(papilio_cimg)
}


# Convert from class rimg to magick-image
papilio_magick <- rimg2magick(papilio)
class(papilio_magick)


pavo documentation built on Sept. 24, 2023, 5:06 p.m.