View source: R/multiLabelMorphology.R
multiLabelMorphology | R Documentation |
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
)
labelsIn |
Input image should contain only 0 for background and positive integers for labels. |
operation |
One of |
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 |
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.
processed labels, of type antsImage.
Cook PA
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.