liveBook · Manning

Erosion

As explained in Geometry for Programmers

Erosion is a morphological operation that shrinks foreground regions or, equivalently, produces an inward offset according to a structuring element.

Erosion shrinks a shape by removing material from its border. Geometrically, it is an inward offset: voxel models lose volume, while a true signed distance function (SDF) receives a positive offset. section 10.2.3 section 12.3.6

Use erosion in practical modeling workflows to:

  • Remove small isolated artifacts and smooth noisy borders before restoring the remaining shape with dilation. section 12.3.3
  • Create a hollow shell by eroding, removing the SDF sign, and dilating the resulting border. section 10.2.4
  • Expose features thinner than a selected wall threshold for early 3D-printing checks. section 12.3.5
  • Patch thin cracks or test spacing by reversing the sequence: dilate first, then erode. section 12.3.5
SDF_dilated = SDF - offset
SDF_eroded = SDF + offset

For a true SDF, erosion is implemented by adding the offset to the function; dilation uses subtraction. section 10.2.3

Binary-image erosion

A reusable implementation inverts a binary image, dilates the inverted image, and inverts it again: erode(img, depth) = invert(dilate(invert(img), depth)). Applying erosion and then proportionate dilation removes a small noisy component while retaining thicker features. section 12.3.2 section 12.3.3

The representation matters. Voxel erosion is fast and reliable when operands share a grid, whereas SDF offsets are correct only while the function remains a true distance function. Boolean operations destroy that property, so post-Boolean erosion can preserve incorrect sharp features. section 10.2.3 section 12.3.6

How Geometry for Programmers covers it

How deep it goes
Explains geometric meaning, SDF arithmetic, binary-image reuse, applications, and the failure after Boolean operations.
Examples
Uses SDF circles, hollow disks, binary voxel images, CT-image noise, thin walls, and thin cracks as concrete examples.
What it assumes
Requires distinguishing true SDFs from post-Boolean shape functions and representing voxel images with filled and empty values.
What you can do after
Apply erosion through SDF arithmetic or an invert-dilate-invert voxel algorithm, then combine it with dilation for cleanup.
How it connects
Connects erosion with dilation, signed distance functions, Boolean operations, voxels, boundary representations, denoising, and 3D printing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.