library(EBImage)
x = readImage(system.file('images', 'shapes.png', package='EBImage'))
x = x[110:512,1:130]
display(x, title='Binary')
y = bwlabel(x)
display(normalize(y), title='Segmented', all=TRUE)
x = readImage(system.file('images', 'nuclei.tif', package='EBImage'))
display(x, all=TRUE)
y = thresh(x, 10, 10, 0.05)
y = opening(y, makeBrush(5, shape='disc'))
display(y, title='Cell nuclei binary mask', all=TRUE)
z = bwlabel(y)
display(normalize(z), title='Cell nuclei', all=TRUE)
nbnuclei = apply(z, 3, max)
cat('Number of nuclei=', paste(nbnuclei, collapse=','),'\n')
## Number of nuclei= 76,86,94,89
cols = c('black', sample(rainbow(max(z))))
zrainbow = Image(cols[1+z], dim=dim(z))
display(zrainbow, title='Cell nuclei (recolored)', all=TRUE)
## Warning in storage.mode(y) = "integer": NAs introduced by coercion
packageVersion("EBImage")
## [1] '4.8.2'
efg
2015-01-18 1923