stackObjects {EBImage}R Documentation

Generate a stack of images for detected objects, one object per image

Description

From an indexed image the functions generates an image stack with one image per object placing each object in the middle of the image. Objects can be automatically rotated to align them along the horizontal axis.

Usage

  ## S4 methods for signatures 'x=IndexedImage,ref=Image,index=character'
  ## and 'x=IndexedImage,ref=Image,index=list'
  ## and 'x=IndexedImage,ref=Image,index=numeric'
  ## S4 method for signature 'IndexedImage, Image,
  ##   missing':
  stackObjects(x, ref, index, combine, rotate, bg.col, ext, ...)
  

Arguments

x An object of IndexedImage. Images must be Grayscale and carry object indexing information, like those returned by watershed or propagate.
ref A reference image containing images of the objects to be stacked using x both as index and the mask. Can be in any color mode.
index Indexes of objects to stack. See details for supported types.
combine Called on a stack if images, specifies if the resulting list of image stacks with individual objects should be combined into a single image stack. Defaults to FALSE.
rotate Specifies if the objects should be aligned rotationally. Defaults to TRUE.
bg.col Color for pixels outside the mask defined by x. Defaults to TRUE.
ext Extension of the target bounding box. See details. If not given, ext is calculated from data.
... Reserved.

Details

The bounding box is set to be a square, which centre coinsides with the geometric center of the object. The ext argument can be used to specified its size, where edge length will be given by 2*ext+1. If ext is not specified, it is calculated from the data by taking the 95% quantile of the vector of h.s2major descriptor of hullFeatures taken over all, objects in the image. This descriptor specifies the extension of the object along its major axis starting from its center.

The size of the bounding box is fixed for all frames to enable combining the resulting frames into a single multiframe image.

index must be coersable to numeric to specify object indexes that are taken into the resulting stack. It can be specified as numeric directly only for images with 1 frame. For images with multiple frames it can be either a list or a character. If specified as a list, it can be a named list of numeric indexes where names are converted to character frame indexes in an arbitrary order, or it can be an unnamed list of the same length as the number of frames. If specifies as character, each element must contain two numbers separated by a dot where the first number is the index of the frame and the second one is the index of the object within the frame, e.g. "2.035" will specify frame 2 and object 35.

Value

An image stack or a list of image stacks if x was itself a stack (contained more than one image).

Author(s)

Oleg Sklyar, osklyar@ebi.ac.uk, 2006-2007

See Also

tile, combine, paintObjects

Examples


  ## load images
  f <- paste( system.file(package="EBImage"), "images/Gene1_G.tif", sep="/" )
  ii = readImage(f)
  ## normalize images
  ii = normalize(ii, separate=TRUE)
  ## segment
  mask = thresh(ii, 25, 25, 0.02)
  ## refine segmentation with morphology filters
  mk3 = morphKern(3)
  mk5 = morphKern(5)
  mask = dilate(erode(closing(mask, mk5), mk3), mk5)
  ## index objects with 'watershed'
  io = watershed( distmap(mask), 1.5, 1)
  if (interactive()) display(io)

  ## stack individual objects
  s = stackObjects(io, ii)
  ## display stack of objects of from the first image
  if (interactive()) display(s[[1]])
  ## combine stacks of objects into a single stack
  s = combine(s)
  ## tile the stack into one frame
  t = tile(s)
  if (interactive()) display(t)
  

[Package EBImage version 2.2.0 Index]