## make objects
x = readImage(system.file('images', 'shapes.png', package='EBImage'))
x = x[110:512,1:130]
y = bwlabel(x)
## number of objects found
max(y)
display(normalize(y), title='Objects')
## remove every second letter
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 number of objects left in each image
apply(z, 3, max)
## perform object removal without re-enumerating
z = rmObjects(y, objects, reenumerate = FALSE)
## labels of objects left
unique(as.vector(z))[-1L]
## re-index objects
z = reenumerate(z)
unique(as.vector(z))[-1L]
Run the code above in your browser using DataLab