Skip to main content

Morphology Operations

The Morphology Operations tool applies mathematical morphology operations to volume or mask objects. These operations modify object shapes based on a structuring element and are fundamental for shape analysis, noise removal, and object separation.

Accessing the Tool

  1. Navigate to the Image tab in the ribbon.
  2. Click Morphology Operations in the Operations section.

Parameters

Target Objects

Select objects to process:

  • Active volume object
  • Active mask object
  • Selected mask objects
  • Visible mask objects
  • All mask objects

Operation Type

OperationDescription
ErodeShrinks objects by removing pixels from boundaries
DilateExpands objects by adding pixels to boundaries
OpenErosion followed by dilation; removes small protrusions
CloseDilation followed by erosion; fills small holes and gaps

Structuring Element

Define the kernel (structuring element) size for the operation:

ParameterDescription
X radius (pixels)Kernel half-width in X direction (1–50)
Y radius (pixels)Kernel half-width in Y direction (1–50)
Z radius (pixels)Kernel half-width in Z direction (1–50)
IsotropicUse the same radius for all directions

The structuring element is a ball (sphere) with the specified radii.


Operation Details

Erode

Erosion removes pixels at object boundaries:

  • Objects shrink inward
  • Small objects may disappear entirely
  • Connections between objects may break
  • Useful for separating touching objects

Effect: A pixel is eroded (set to background) if any part of the structuring element extends outside the object.

Dilate

Dilation adds pixels at object boundaries:

  • Objects grow outward
  • Small gaps between objects may close
  • Useful for filling small holes
  • Can connect nearby objects

Effect: A pixel is dilated (set to foreground) if any part of the structuring element touches the object.

Open (Erosion → Dilation)

Opening removes small bright features and thin connections:

  • Smooths object contours
  • Removes small protrusions (spurs)
  • Breaks thin bridges between objects
  • Preserves overall object shape

Use case: Cleaning up noisy segmentations by removing small artifacts.

Close (Dilation → Erosion)

Closing fills small dark features and gaps:

  • Smooths object contours
  • Fills small holes
  • Connects nearby objects
  • Bridges narrow breaks

Use case: Completing segmentations by filling internal holes.


Workflow

  1. Open the Morphology Operations tool.
  2. Select target objects from the dropdown.
  3. Choose the operation type (Erode, Dilate, Open, Close).
  4. Set the structuring element radii.
  5. Enable Isotropic for uniform processing in all directions.
  6. Click Apply to perform the operation.

Use Cases

Separating Touching Objects

When segmented objects touch and need to be separated:

  1. Apply Erode with appropriate radius.
  2. Objects shrink and separate.
  3. Use connected component analysis to label individual objects.
  4. Optionally Dilate to restore approximate original size.

Filling Holes in Segmentation

When segmentation contains unwanted internal holes:

  1. Apply Close with radius larger than the holes.
  2. Holes are filled while outer boundaries remain similar.

Removing Small Artifacts

When segmentation contains small noise spots:

  1. Apply Open with radius larger than the artifacts.
  2. Small isolated regions disappear.
  3. Larger objects remain with smoothed boundaries.

Smoothing Jagged Boundaries

For cleaner segmentation edges:

  1. Apply Close followed by Open, or vice versa.
  2. Jagged edges become smoother.
  3. Adjust radii to control smoothing strength.

Parameter Guidelines

ScenarioOperationSuggested Radius
Remove small spotsOpen2–5 pixels
Fill small holesClose2–5 pixels
Separate objectsErodeDepends on gap needed
Smooth boundariesOpen + Close1–3 pixels
tip

Use smaller radii for subtle adjustments and larger radii for more aggressive modifications. Preview results before applying to large datasets.


2D vs 3D Processing

The structuring element operates in 3D when Z radius > 0:

Z RadiusProcessing Mode
1 (or more)Full 3D morphology
Very smallApproximately slice-by-slice
info

For consistent 3D objects, use similar radii in all directions (isotropic). For slice-based data, you may want smaller Z radius.


Scripting

Morphological operations are available via the Python scripting API.

import ScriptingApi as api

app = api.Application()
volume_operations = app.get_volume_operations()

# Erode with ball radius [7, 7, 1] pixels
volume_operations.morphological_operation(
["Volume1"],
api.MorphologicalOperation.Erode,
[7, 7, 1] # radius [x, y, z]
)

# Dilate
volume_operations.morphological_operation(["Volume1"], api.MorphologicalOperation.Dilate, [5, 5, 5])

# Open
volume_operations.morphological_operation(["Volume1"], api.MorphologicalOperation.Open, [3, 3, 3])

# Close
volume_operations.morphological_operation(["Volume1"], api.MorphologicalOperation.Close, [3, 3, 3])

See the VolumeOperations API Reference for details.

warning

Morphological operations modify data directly. Excessive erosion may remove important structures; excessive dilation may merge separate objects.