SVG feMorphology Radius Attribute Visual Changes

The feMorphology SVG filter primitive alters the boundaries of shapes, text, and graphics by either expanding or shrinking them. The radius attribute directly controls the extent of this transformation, determining the pixel distance by which edges are altered. Depending on whether the filter is set to dilute or erode an element, adjusting the radius results in dramatic visual transformations ranging from subtle weight adjustments and bolding to complete dissolution or merging of shapes.

Understanding the Radius Attribute

The radius attribute defines the size of the structuring element used to perform the morphological operation. It accepts either a single number or two space-separated numbers:

The visual outcome of changing the radius depends entirely on the operator attribute: dilate or erode.

Visual Changes with Dilate (operator="dilate")

When the operator is set to dilate, increasing the radius value causes the graphic to expand outward, thickening its visual footprint.

Visual Changes with Erode (operator="erode")

When the operator is set to erode, increasing the radius value eats away at the edges of the graphic, shrinking its visual footprint.

Directional Morphing via Asymmetrical Radius

When two distinct values are provided to the radius attribute, the visual changes become asymmetrical: