library(EBImage)
x <- readImage(system.file('images', 'shapes.png', package='EBImage'))
x <- x[110:512,1:130]
y <- bwlabel(x)
max(y)
## [1] 7
display(normalize(y), title='Objects')
objects <- list( seq.int(from=2, to=max(y), by=2),
seq.int(from=1, to=max(y), by=2)
)
z <- rmObjects(combine(y, y), objects)
display(normalize(z), title='Object removal')
## The image contains more than one frame: only the first one is displayed. To display all frames use 'all = TRUE'.
apply(z, 3, max)
## [1] 4 3
z <- rmObjects(y, objects, reenumerate = FALSE)
unique(as.vector(z))[-1L]
## [1] 1 3 5 7
z <- reenumerate(z)
unique(as.vector(z))[-1L]
## [1] 1 2 3 4
packageVersion("EBImage")
## [1] '4.8.2'
efg
2015-01-18 2016