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

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.

Value

processed labels, of type antsImage.

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.

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)
#> LabelValue Mean Min Max Variance Count Volume Mass x y #> 3 0 0.01395981 0 2 0.02578888 64041 64041 0 0.0000 0.0000 #> 1 1 2.00000000 2 2 0.00000000 216 216 432 149.5185 156.9815 #> 2 2 2.00000000 2 2 0.00000000 1279 1279 2558 124.5676 130.9805 #> z t #> 3 NA NA #> 1 NA NA #> 2 NA NA