multiLabelMorphology: Morphology on multi label images.

View source: R/multiLabelMorphology.R

multiLabelMorphologyR Documentation

Morphology on multi label images.

Description

Wraps calls to iMath binary morphology. Additionally, dilation and closing operations preserve pre-existing labels. The choices of operation are:

Usage

multiLabelMorphology(
  labelsIn,
  operation,
  radius,
  dilationMask = NULL,
  labelList = NA
)

Arguments

labelsIn

Input image should contain only 0 for background and positive integers for labels.

operation

One of 'MD', 'ME', 'MC', 'MO', passed to iMath.

radius

radius of the morphological operation.

dilationMask

Optional binary mask to constrain dilation only (eg dilate cortical label into WM).

labelList

Optional list of labels, to perform operation upon. Defaults to all unique intensities in labels.in.

Details

Dilation: dilates all labels sequentially, but does not overwrite original labels. This reduces dependence on the intensity ordering of adjoining labels. Ordering dependence can still arise if two or more labels dilate into the same space - in this case, the label with the lowest intensity is retained. With a mask, dilated labels are multiplied by the mask and then added to the original label, thus restricting dilation to the mask region.

Erosion: Erodes labels independently, equivalent to calling iMath iteratively.

Closing: Close holes in each label sequentially, but does not overwrite original labels. Opening: Opens each label independently, equivalent to calling iMath iteratively.

Value

processed labels, of type antsImage.

Author(s)

Cook PA

Examples


img <- antsImageRead(getANTsRData("r16"), 2)
labels <- getMask(img, 1, 150) + getMask(img, 151, 225) * 2
labelsDilated <- multiLabelMorphology(labels, "MD", 2)

# should see original label regions preserved in dilated version
# label N should have mean N and 0 variance
labelStats(labelsDilated, labels)

stnava/ANTsR documentation built on March 24, 2024, 6:13 a.m.