Description Usage Arguments Value Author(s) See Also Examples
View source: R/rfSegmentation.R
Unsupervised image segmentation via random forests. An example.
1 2 3 4 5 6 7 | rfSegmentation(
featureMatrix,
mask,
labelimg = NULL,
ntrees = 100,
verbose = FALSE
)
|
featureMatrix |
input matrix of features matched to mask size n predictors in rf |
mask |
input antsImage mask |
labelimg |
input antsImage labelimage, optional for supervised seg |
ntrees |
number of rf trees |
verbose |
boolean |
list of n-probability images is output where n is number of classes
Tustison NJ, Avants BB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
if ( usePkg("randomForest") ) {
img<-antsImageRead( getANTsRData("r16") ) %>% iMath("Normalize")
mask<-getMask( img )
segs<-kmeansSegmentation( img, k=3, kmask = mask)
fmat0 = t( antsrimpute( getNeighborhoodInMask( img, mask, c(2,2) ) ) )
fmat1 = t( antsrimpute( getNeighborhoodInMask(
segs$probabilityimages[[1]], mask, c(2,2) ) ) )
fmat2 = t( antsrimpute( getNeighborhoodInMask(
segs$probabilityimages[[2]], mask, c(2,2) ) ) )
fmat3 = t( antsrimpute( getNeighborhoodInMask(
segs$probabilityimages[[3]], mask, c(2,2) ) ) )
fmat = cbind( fmat0, fmat1, fmat2, fmat3 )
# produces proximity between all voxel pairs
rfsegs<-rfSegmentation( fmat, verbose=FALSE )
lrr = lowrankRowMatrix( rfsegs, 10, faster = TRUE )
nv = eanatSelect( inmat=lrr, mask=mask, selectorScale=1.2, cthresh=50,
verbose=T, smooth=1 )
ee = eanatDef( lrr, mask, nvecs=nv, smooth=0., cthresh=50,
its=2, verbose=TRUE )
eseg = eigSeg( mask, ee )
plot( img, eseg )
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.