Understanding GIMP GEGL Distance Map Filter
The GEGL Distance Map filter in GIMP is an image processing tool that calculates and visualizes the spatial distance between pixels and the nearest edge or boundary of a shape. This article explains the primary function of the Distance Map filter, how it operates behind the scenes, and how it can be applied in design workflows such as 3D bump mapping, procedural shading, and complex selection masking.
What is the GEGL Distance Map?
The GEGL Distance Map filter computes a distance transform on an image layer or selection. It evaluates the content of an image—typically a high-contrast black-and-white shape or alpha mask—and replaces each pixel with a grayscale value representing how far that pixel is from the closest boundary.
Pixels located directly on an edge are rendered as black (or minimum value), while pixels located deeper inside (or outside) the shape progressively transition to white (or maximum value) as the distance increases.
How the Filter Works
The filter scans the input image and applies a mathematical distance metric to determine the proximity of pixels to the boundary of a subject:
- Euclidean Distance: Calculates the true straight-line distance, producing smooth, circular gradients around corners.
- Manhattan Distance (City Block): Measures distance strictly along horizontal and vertical grid paths, creating diamond-shaped gradient patterns.
- Chebyshev Distance (Chessboard): Measures distance based on the greatest single axis difference, resulting in square gradient contours.
Users can choose to map distances inside the shape, outside the shape, or both, as well as normalize the values to ensure the maximum distance spans the full 0–255 grayscale range.
Practical Use Cases in GIMP
1. 3D Bump Maps and Height Maps
The smooth gradient generated by the Distance Map is ideal for bump mapping and displacement. Applying this map to lighting or emboss filters gives flat 2D shapes, text, or logos a realistic, curved 3D profile.
2. Custom Bevels, Glows, and Outlines
By mapping distance, the filter creates perfectly uniform inner and outer contours. Designers use this output to generate custom neon glows, complex stroke outlines, or rounded bevel effects that scale evenly regardless of shape complexity.
3. Advanced Masking and Edge Feathering
Standard feathering applies a simple blur, which can distort sharp geometry. A distance map allows for mathematically precise falloffs, making it useful for creating custom masks, depth-of-field effects, and edge-erosion techniques.
4. Procedural Texture and Pattern Generation
When applied to scattered points or binary noise, the distance map forms Voronoi-like cellular structures, which serve as foundational textures for organic surfaces like stone, reptile skin, or cracked earth.