plotImage: Plot JP(E)G/PNG/Raster/RGB images

View source: R/plotImage.R

plotImageR Documentation

Plot JP(E)G/PNG/Raster/RGB images

Description

This function takes in an image-related object - path to JP(E)G/PNG file, raster object, RGBarray. It returns a ggplot object with the selected image.

Arguments

x

A variety of objects can be passed: character string corresponding to an image file path, valid file types are JPG, JPEG and PNG. It can also take as input objects of class raster and RGB arrays. It can also take a SpatialExperiment from which the image will be extracted.

slice

Character string indicating which image slice to use when SpatialExperiment objects are passed. By default uses the first slice available.

Value

ggplot object

Author(s)

Marc Elosua Bayes & Helena L Crowell

Examples

# Filename
path <- file.path(
  system.file(package = "SPOTlight"), 
  "extdata/SPOTlight.png")
plotImage(x = path)
# array
png_img <- png::readPNG(path)
plotImage(png_img)
# SpatialExperiment

MarcElosua/SPOTlight documentation built on March 7, 2024, 4:58 p.m.