segmentationToOneHot: One-hot encoding function

View source: R/oneHotSegmentation.R

segmentationToOneHotR Documentation

One-hot encoding function

Description

Basic one-hot transformation of segmentations array.

Usage

segmentationToOneHot(
  segmentationsArray,
  segmentationLabels = NULL,
  channelFirstOrdering = FALSE
)

Arguments

segmentationsArray

multi-label numpy array

segmentationLabels

vector of segmentation labels. Note that a background label (typically 0) needs to be included.

channelFirstOrdering

Specifies the ordering of the dimensions.

Value

an n-D array of shape where the segmentation labels are expanded in a one-hot fashion in the channels dimension.

Author(s)

Tustison NJ

Examples


r16 <- antsImageRead( getANTsRData( "r16" ) )
seg <- kmeansSegmentation( r16, 3 )$segmentation
oneHot <- segmentationToOneHot( as.array( seg ) )

r16 <- antsImageRead( getANTsRData( "r16" ) )
seg <- kmeansSegmentation( r16, 3 )$segmentation
oneHot <- segmentationToOneHot( as.array( seg ),
                                channelFirstOrdering = TRUE )


neuroconductor-devel/ANTsR documentation built on July 3, 2025, 10:41 p.m.