rfSegmentationPredict: A rfSegmentationPredict function.

View source: R/rfSegmentation.R

rfSegmentationPredictR Documentation

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

Author(s)

Tustison NJ, Avants BB

Examples


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)
}


stnava/ANTsR documentation built on April 16, 2024, 12:17 a.m.