rmObjects {EBImage} | R Documentation

## Delete objects

### Description

The `rmObjects` functions deletes objects indexed by a list of integer vectors (indexes) from an image with indexed objects.

### Usage

        # S4 methods for class 'Image':

        rmObjects(x, index)

### Arguments

`x`
  An object of `Image-class` in the `Grayscale` mode with integer-absed object index, as returned by `watershed`.
`index`
  A list of integer vectors (one vector per image) with indexes of existing objects that will be deleted.

### Value

An image of `Image-class`, same as in `watershed`.

### Author(s)

Oleg Sklyar: osklyar@ebi.ac.uk

### See Also

`Image-class, watershed, getObjects, paintObjects`

### Examples

      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) )

      }

[Package EBImage version 2.0.1 Index]