ants.ops.morphology

morphology(image, operation, radius, mtype='binary', value=1, shape='ball', radius_is_parametric=False, thickness=1, lines=3, include_center=False)[source]

Apply morphological operations to an image

ANTsR function: morphology

Parameters:
  • input (ants.core.ANTsImage) – input image

  • operation (str) –

    operation to apply

    ”close” Morpholgical closing “dilate” Morpholgical dilation “erode” Morpholgical erosion “open” Morpholgical opening

  • radius (scalar) – radius of structuring element

  • mtype (str) –

    type of morphology

    ”binary” Binary operation on a single value “grayscale” Grayscale operations

  • value (scalar) – value to operation on (type=’binary’ only)

  • shape (str) –

    shape of the structuring element ( type=’binary’ only )

    ”ball” spherical structuring element “box” box shaped structuring element “cross” cross shaped structuring element “annulus” annulus shaped structuring element “polygon” polygon structuring element

  • radius_is_parametric (bool) – used parametric radius boolean (shape=’ball’ and shape=’annulus’ only)

  • thickness (scalar) – thickness (shape=’annulus’ only)

  • lines (int) – number of lines in polygon (shape=’polygon’ only)

  • include_center (bool) – include center of annulus boolean (shape=’annulus’ only)

Return type:

ants.core.ANTsImage

Example

>>> import ants
>>> fi = ants.image_read( ants.get_ants_data('r16') , 2 )
>>> mask = ants.get_mask( fi )
>>> dilated_ball = ants.morphology( mask, operation='dilate', radius=3, mtype='binary', shape='ball')
>>> eroded_box = ants.morphology( mask, operation='erode', radius=3, mtype='binary', shape='box')
>>> opened_annulus = ants.morphology( mask, operation='open', radius=5, mtype='binary', shape='annulus', thickness=2)