| rmObjects {EBImage} | R Documentation |
The rmObjects functions deletes objects indexed by a list of
integer vectors (indexes) from an image with indexed objects.
# S4 methods for class 'Image':
rmObjects(x, index)
xImage-class in the
Grayscale mode with integer-absed object index, as
returned by watershed. index
An image of Image-class, same as in watershed.
Oleg Sklyar: osklyar@ebi.ac.uk
Image-class, watershed, getObjects, paintObjects
if ( interactive() ) {
ddir <- paste( system.file(package="EBImage"), "images", sep="/" )
a <- read.image( paste(ddir, "A04w1.jpg", sep="/") )
w <- watershed( distmap( thresh(a, 10, 10) ) )
display( normalize(w) )
## Not run: Often one need to delete small objects, here is the
## Not run: straightfoward way to construct an index
index <- lapply( getObjects(w), function(x) which( x[, "size"] < 30) )
## Not run: now we delete these small objects
w <- rmObjects( w, index )
display( normalize(w) )
}