Learn R Programming

ANTsR (version 0.3.3)

rfSegmentationPredict: A rfSegmentationPredict function.

Description

Predict image segmentation via random forests.

Usage

rfSegmentationPredict(rfSegmentationModel, featureMatrix, mask, verbose = FALSE)

Arguments

rfSegmentationModel
input rf model
featureMatrix
input feature matrix
mask
antsImage mask
verbose
bool

Value

segmentation is output

Examples

Run this code

if ( usePkg('randomForest') ) {
img<-antsImageRead( getANTsRData("r16"))
mask<-getMask( img )
mask2<-getMask( img )
mask [ 129:255, 1:255 ]<-0
mask2[ 2:128, 1:255 ]<-0
segs<-kmeansSegmentation( img, k=3, kmask = mask)
fmat = t( antsrimpute( getNeighborhoodInMask( img, mask, c(2,2) ) ) )
rfsegs<-rfSegmentation(  fmat, mask, segs$segmentation, ntrees=100 )
fmat2 = t( antsrimpute( getNeighborhoodInMask( img, mask2, c(2,2) ) ) )
rfseg2<-rfSegmentationPredict(  rfsegs$rfModel , fmat2 , mask2 )
}

Run the code above in your browser using DataLab