watershed {EBImage}R Documentation

Watershed transformation and watershed based object detection

Description

Watershed transformation and watershed based object detection.

Usage

    watershed(x, tolerance=1, ext=1)

Arguments

x
An object of Image-class in the Grayscale mode.
tolerance
The minimum height of the object in the units of image intensity between its highest point (seed) and the point where it contacts another object (checked for every contact pixel). If the height is smaller than the tolerance, the object will be combined with one of its neighbors, which is the highest. It is assumed that the function is run on a distance map, therefore the default value is 1. If running the function on an original grayscale image with intensity range [0,1] one should modify this value, down to 0.1 or other which is image specific.
ext
Extension of the neighborhood for the detection of neighboring objects. Higher value smoothes out small objects.

Value

An object of Image-class in the Grayscale with separate objects indexed be positive integers starting from 1. To preview the results visually, use display( normalize(result) ) or use it in combination with paintObjects.

Details

The algorithm identifies and separates objects that stand out of the background (zero), in other words to use the water fill, the source image is flipped upside down and the resulting valleys (values with higher intensities) are filled in first until another object or background is met. The deepest valleys (pixels with highest intensity) become indexed first.

Author(s)

Oleg Sklyar: osklyar@ebi.ac.uk

See Also

Image-class, distmap, thresh, getObjects, \code{matchObjects}

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 needs to delete small objects
    ## Not run: here is the straightforward way to construct the index
    index <- lapply( getObjects(w), function(x) which( x[, "size"] < 40) )
    w <- rmObjects(w, index)
    display( normalize(w) )

  }

[Package EBImage version 2.0.1 Index]