RNotes | EBImage


library(EBImage)

Places detected objects into an image stack.

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', 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', 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', all=TRUE)

Stacked cells

st <- stackObjects(cmask, img)
display(st, title='Stacked objects', all=TRUE)

Related: Slides 13-17 in Wolfgang Huber’s presentation Machine learning in high-throughput screening and automated phenotyping [~35 MB].


packageVersion("EBImage")
## [1] '4.8.2'

efg
2015-01-18 1959