interleave: Interleave Images in an Array

View source: R/interleave.R

interleaveR Documentation

Interleave Images in an Array

Description

Interleave images in an array of grayscale or color images

Usage

interleave(x, n)

Arguments

x

an array of Image objects with 3- or 4-dimensions

n

the number of adjacent images

Details

This function will create a new Image object from an array of grayscale or color Image objects by interleaving every n-th render frame. The motivation behind this function is to simplify the task of reordering an array that was generated by sequentially combining groups of images so that related images are adjacent.

Note that if the number of images (frames) is not an even multiple of n, the excess frames will be dropped with a warning. This generally indicates an error.

As a typical application, three different images (DAPI, FITC, and Cy5) are taken of many separate fields of cells. The images are separated then colorized as a group. Then groups are then combined with combine(...) or abind(..., along = 4). Plotting the resulting image with plot(..., all= TRUE) shows the images arranged sequentially with all of the DAPI images first, followed by all of the FITC images and then all the Cy5 images. Interleaving this image with n = 3 reorganizes the stack so that images from the same field are next to each other as DAPI, FITC, Cy5, DAPI, FITC, Cy5, etc.

Value

array of Image objects with the final dimension permuted

Examples

# Example of DAPI + Fluorescent + Merged pairs
  x <- readImage(system.file("extdata", "cells.tif", package="EBImageExtra"))
  nuc <- x[,,c(1,3)]
  cel <- x[,,c(2,4)]
  img <- rgbImage(red = 0.1 * cel, green = cel + 0.2 * nuc, blue = 0.4 * nuc)
  stk <- combine(toRGB(0.5*nuc), toRGB(cel), img)

# Original order
  plotStack(stk, label = TRUE, nx = 3)

# "Interleaved" order
  plotStack(interleave(stk, n = 3), label = c("DAPI", "Fluor", "Merged"), nx = 3)


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