Last data update: 2014.03.03

R: Places detected objects into an image stack
stackObjectsR Documentation

Places detected objects into an image stack

Description

Places detected objects into an image stack.

Usage

stackObjects(x, ref, combine=TRUE, bg.col='black', ext)

Arguments

x

An Image object or an array containing object masks. Object masks are sets of pixels with the same unique integer value.

ref

An Image object or an array, containing the intensity values of the objects.

combine

If x contains multiple images, specifies if the resulting list of image stacks with individual objects should be combined using combine into a single image stack.

bg.col

Background pixel color.

ext

A numeric controlling the size of the output image. If missing, ext is estimated from data. See details.

Details

stackObjects creates a set of n images of size (2*ext+1, 2*ext+1), where n is the number of objects in x, and places each object of x in this set.

If not specified, ext is estimated using the 98% quantile of m.majoraxis/2, where m.majoraxis is the semi-major axis descriptor extracted from computeFeatures.moment, taken over all the objects of the image x.

Value

An Image object containing the stacked objects contained in x. If x contains multiple images and if combine is TRUE, stackObjects returns a list of Image objects.

Author(s)

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

See Also

combine, tile, computeFeatures.moment

Examples

  ## simple example
  x = readImage(system.file('images', 'shapes.png', package='EBImage'))
  x = x[110:512,1:130]
  y = bwlabel(x)
  display(normalize(y), title='Objects')
  z = stackObjects(y, normalize(y))
  display(z, title='Stacked objects')

  ## load images
  nuc = readImage(system.file('images', 'nuclei.tif', package='EBImage'))
  cel = readImage(system.file('images', 'cells.tif', package='EBImage'))
  img = rgbImage(green=cel, blue=nuc)
  display(img, title='Cells')

  ## segment nuclei
  nmask = thresh(nuc, 10, 10, 0.05)
  nmask = opening(nmask, makeBrush(5, shape='disc'))
  nmask = fillHull(bwlabel(nmask))

  ## segment cells, using propagate and nuclei as 'seeds'
  ctmask = opening(cel>0.1, makeBrush(5, shape='disc'))
  cmask = propagate(cel, nmask, ctmask)

  ## using paintObjects to highlight objects
  res = paintObjects(cmask, img, col='#ff00ff')
  res = paintObjects(nmask, res, col='#ffff00')
  display(res, title='Segmented cells')

  ## stacked cells
  st = stackObjects(cmask, img)
  display(st, title='Stacked objects')

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(EBImage)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/EBImage/stackObjects.Rd_%03d_medium.png", width=480, height=480)
> ### Name: stackObjects
> ### Title: Places detected objects into an image stack
> ### Aliases: stackObjects
> 
> ### ** Examples
> 
>   ## simple example
>   x = readImage(system.file('images', 'shapes.png', package='EBImage'))
>   x = x[110:512,1:130]
>   y = bwlabel(x)
>   display(normalize(y), title='Objects')
>   z = stackObjects(y, normalize(y))
>   display(z, title='Stacked objects')
Only the first frame of the image stack is displayed.
To display all frames use 'all = TRUE'.
> 
>   ## load images
>   nuc = readImage(system.file('images', 'nuclei.tif', package='EBImage'))
>   cel = readImage(system.file('images', 'cells.tif', package='EBImage'))
>   img = rgbImage(green=cel, blue=nuc)
>   display(img, title='Cells')
Only the first frame of the image stack is displayed.
To display all frames use 'all = TRUE'.
> 
>   ## segment nuclei
>   nmask = thresh(nuc, 10, 10, 0.05)
>   nmask = opening(nmask, makeBrush(5, shape='disc'))
>   nmask = fillHull(bwlabel(nmask))
> 
>   ## segment cells, using propagate and nuclei as 'seeds'
>   ctmask = opening(cel>0.1, makeBrush(5, shape='disc'))
>   cmask = propagate(cel, nmask, ctmask)
> 
>   ## using paintObjects to highlight objects
>   res = paintObjects(cmask, img, col='#ff00ff')
>   res = paintObjects(nmask, res, col='#ffff00')
>   display(res, title='Segmented cells')
Only the first frame of the image stack is displayed.
To display all frames use 'all = TRUE'.
> 
>   ## stacked cells
>   st = stackObjects(cmask, img)
>   display(st, title='Stacked objects')
Only the first frame of the image stack is displayed.
To display all frames use 'all = TRUE'.
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>