labelStack: Label Frames of an Image Stack

View source: R/labelStack.R

labelStackR Documentation

Label Frames of an Image Stack

Description

Add labels to a plotted image stack

Usage

labelStack(
  x,
  labels = TRUE,
  nx,
  col = "white",
  offset = c(0.95, 0.05),
  adj = c(1, 1),
  ...
)

Arguments

x

A recently plotted Image object or array of such objects

labels

Either a logical value (default of TRUE) to number each frame or a vector of labels to be applied to each frame.

nx

The number of frames in the x-direction of the image stack. If missing, a square tile of images will be assumed.

col

Color of the label to be added.

offset

A numeric vector of length 1 or 2 specifying the position of the label in each frame with default values of c(0.95, 0.05) to place the label at the top right corner. Note that this default differs from that in plotStack.

adj

One or two values in [0, 1] which specify the x (and optionally y) adjustment or "justification" of the label where 0 indicates left/bottom, 1 indicates right/top, and 0.5 centered. Note that this default differs from that in plotStack. See the text function for details.

...

Additional values passed to text for labeling/

Details

This code is called after having plotted an Image object, typically by plotStack or plot(img, all = TRUE). If labels is TRUE, each frame of the image will be labeled by frame number. If FALSE, no labeling will occur. Otherwise, labels generated by as.graphicsAnnot will be placed in the top right corner of each frame by default or according to offset and adj.

Value

The image x is invisibly returned to permit passing the argument through a pipe. This function primarily called to label a plotted image.

See Also

plotStack, which allows for automatically labeling the plotted image and locatorStack, which provides an interface for selecting frames from the stack.

Examples

lighthouse <- readImage(system.file("extdata", "lighthouse.jpg", package="EBImageExtra"))
x <- EBImage::untile(lighthouse, c(4, 3), lwd = 0)
idx <- sample(1:12)
plotStack(x[,,,idx], label = TRUE)
labelStack(x, labels = paste("Original:", idx), offset = 0.5, adj = 0.5, col = "yellow")


ornelles/EBImageExtra documentation built on Aug. 10, 2022, 11:44 p.m.