watershed {EBImage} | R Documentation |
Watershed transformation and watershed based object detection.
watershed(x, tolerance=1, ext=1)
x
Image-class
in the
Grayscale
mode. tolerance
[0,1]
one should modify this value, down to 0.1
or other which is image specific. ext
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
.
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.
Oleg Sklyar: osklyar@ebi.ac.uk
Image-class, distmap, thresh, getObjects,
\code{matchObjects}
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) ) }