M 051 / 18302 Masks & Controlalgorithm output

Distance Transform

segmentation, masks & control

Typeface · IBM Plex Mono

Real-world algorithm demonstration, applied to a NASA portrait.
Real-world algorithm demonstration, applied to a NASA portrait.Image: NASA / Eileen Collins · scikit-image (public domain)View source ↗

Prompt

Transform this image into a Distance Transform visualization, isolating the main foreground silhouettes against solid black. Make their boundaries dark and increase grayscale brightness progressively toward points deepest inside each shape, producing smooth interior ridges rather than directional illumination or photographic shading. Keep the original subject and composition.

Identify

Brightness increases with distance to the mask boundary1.

Principle

For each foreground pixel2, the distance to the nearest zero is measured.

Try it out

Change the initial mask.

Classification

Calculated image processing result.

Further examples · 8 images

Markazi province distance map
02 Markazi province distance mapA map of Iran shows concentric color bands expanding from a central point. It represents a distance transform where intensity or color changes based on the Euclidean distance from a specific origin.Fdmfi · CC BY-SA 3.0 · Wikimedia Commons
Distance to the sea in Asia
03 Distance to the sea in AsiaThe map displays green isolines indicating distance from the coastline. It serves as a geographic application of the distance transform, where the mask boundary is the continental edge and pixel values represent distance to it.Gaianauta · CC BY-SA 4.0 · Wikimedia Commons
Medial axis example 2d
04 Medial axis example 2dA geometric diagram showing the medial axis and inscribed circles. This relates to the distance transform, as the medial axis consists of the local maxima of a distance transform field.Pblanke · Public domain · Wikimedia Commons
Medial axis and average
05 Medial axis and averageGeometric shapes paired with their topological skeletons. This demonstrates the outcome of thinning processes derived from distance transform calculations to find the central axis of a binary mask.Matankic · CC0 · Wikimedia Commons
Medial axis and average2
06 Medial axis and average2A shape and its medial axis are shown in red. The red lines represent the points where the distance to the boundary is locally maximal, a direct application of the distance transform.Matankic · CC0 · Wikimedia Commons
Medial lfs
07 Medial lfsCircles are used to show the distance from internal points to the nearest boundary. This geometric construction explains the underlying logic of calculating a distance transform for a 2D shape.RuppertsAlgorithm · CC0 · Wikimedia Commons
Nf1 grassfire grid discretized gradient
08 Nf1 grassfire grid discretized gradientA grayscale map shows intensity varying based on proximity to a black obstacle and a red goal. The gradient represents a calculated distance field, characteristic of the distance transform.User:Trolli101 · CC BY-SA 3.0 · Wikimedia Commons