Learn R Programming

ANTsR (version 1.0)

rfSegmentationPredict: A rfSegmentationPredict function.

Description

Predict image segmentation via random forests.

Usage

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

Arguments

rfSegmentationModel

input rf model

featureimages

input list of antsImage feature images

mask

antsImage mask

verbose

bool

Value

segmentation is output

Examples

Run this code
# NOT RUN {
if ( usePkg('randomForest') ) {
img<-antsImageRead( getANTsRData("r16"))
mask<-getMask( img )
mask2<-getMask( img )
mask<-iMath(mask,'ME',25)
mask2[ mask == 1 ]<-0
segs<-kmeansSegmentation( img, k=3, kmask = mask)
fimgs<-list( img )
rfsegs<-rfSegmentation( segs$segmentation, fimgs , ntrees=100 )
rfseg2<-rfSegmentationPredict(  rfsegs$rfModel , fimgs , mask2 )
plot( rfseg2 )
# }
# NOT RUN {
   img<-antsImageRead( getANTsRData("r16"))
   img2<-antsImageRead( getANTsRData("r64"))
   mask<-getMask( img )
   mask2<-getMask( img2 )
   segs<-kmeansSegmentation( img, k=3, kmask = mask)
   nimg<-iMath(img,"Normalize")
   fimgs<-list( nimg )
   rfsegs<-rfSegmentation( segs$segmentation, fimgs , ntrees=100 )
   mytx<-antsRegistration(fixed=img , moving=img2 ,
            typeofTransform = c('SyN') )
   fimgs2<-list( iMath(mytx$warpedmovout,"Normalize") )
   rfseg2<-rfSegmentationPredict(  rfsegs$rfModel , fimgs2 , mask )
   plot( rfseg2 )
   
# }
# NOT RUN {
}
# }

Run the code above in your browser using DataLab