RNotes | EBImage


library(EBImage)

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(nmask)
nmask <- bwlabel(nmask)
display(normalize(nmask), title='Cell nuclei mask', all=TRUE)

Segment Cells: use propagate and nuclei as ‘seeds’

ctmask <- opening(cel>0.1, makeBrush(5, shape='disc'))
cmask <- propagate(cel, nmask, ctmask)
display(normalize(cmask), title='Cell mask', all=TRUE)

Use paintObjects to highlight objects

res <- paintObjects(cmask, img, col='#ff00ff')
res <- paintObjects(nmask, res, col='#ffff00')
display(res, title='Segmented cells', all=TRUE)


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

efg
2015-01-18 2020