Skip to content
Distortionary

Filter 05 · Masks · 0.1 beta

Octodoctor

Masks from gradients and keys, snapped to edges.

A mask is a stack of up to eight layers. Each is a directional gradient or a key on one of the image’s channels, and each goes through the same response curve, so combining them takes one blend mode. “Blue, but only near the top of the frame” is a sky mask. An edge-aware pass then pulls the transitions onto real edges in the photograph.

  • GIMP 3
  • Photoshop
  • Desktop app
  • Command line · Enterprise
A coastal road under a cloudy sky, with everything but the blue sky tinted red to show the mask.
Before After
Coastal road. The sky preset, shown as an overlay: red is unselected. Photo: David Berube.
$ octodoctor road.png -p sky -m overlay

The command that rendered it. Command-line tools come with Enterprise.

4 steps, each doing one thing.

  1. 01

    Read a source

    Linear, reflected, radial or conic gradients, placed by center, angle and length. Or a channel: red, green, blue, alpha, Rec. 709 luma, OKLab lightness, OKLCh chroma and hue, or the OKLab opponent axes.

  2. 02

    Shape it

    Highpass, lowpass, bandpass or bandstop around a midpoint, with ramp width, skew, easing, and output levels. On hue and conic sources, distance is measured around the circle, so a band around red catches both sides of zero.

  3. 03

    Feather and blend

    A Gaussian feather, optional invert, then normal, add, subtract, multiply, screen, overlay, min, max or difference onto the layers below, at any opacity. 1

  4. 04

    Clean up

    Grow or shrink over a near-round octagon. Refine with a guided filter steered by OKLab lightness, which pulls a plain gradient onto a horizon line or tightens a ragged hue key around its subject. Then blur, levels, gamma. Every step costs the same at any radius. 2,3

A white sky mask over black land.
Before After
sky: blue, in the upper part of the frame. Photo: David Berube.
A mask selecting the green hillside.
Before After
foliage: yellow-greens and greens. Photo: David Berube.
A soft horizontal band across the middle of the frame.
Before After
horizon: a band across the middle. Photo: David Berube.
A mask selecting the bright center of the vulture photograph.
Before After
spotlight: bright areas near the center. Photo: David Berube.

Every control, named.

The same names in every host and in the JSON presets. With an Enterprise license, the command-line tool reads those presets and runs them on a thousand files.

Name Range Effect
source 4 gradients, 11 channels What each layer reads.
band highpass · lowpass · bandpass · bandstop Which part of the source is kept.
midpoint · width · plateau 0–1 or degrees Where the band sits and how soft it is.
blend 9 modes How a layer meets the ones below.
grow pixels, ± Max or min filter.
refine pixels Edge-aware snap onto the photograph.
output mask · cutout · overlay Gray mask, alpha cut-out, or a tinted check.
GIMP 3
A native GIMP 3 plug-in written in C, with the filter linked in statically. GIMP 3.0 or later, Linux and Windows.
Photoshop
A UXP panel running the filter as WebAssembly. Photoshop 2024 (25.0) or later, macOS and Windows.
Command line
Enterprise only. The same filter as a command-line tool, for batches, build scripts and render farms. Settings load from JSON presets.
  • He, Sun and Tang (2010)

    Guided image filtering. The refine step.

  • Ottosson (2020)

    OKLab and OKLCh, the color keys.

  1. 1

    Porter and Duff (1984). Compositing digital images. SIGGRAPH ’84.

  2. 2

    Crow (1984). Summed-area tables for texture mapping. SIGGRAPH ’84.

  3. 3

    Heckbert (1986). Filtering by repeated integration. SIGGRAPH ’86.

Octodoctor isn’t packaged yet.

The plug-ins that are ready are on the pricing page.

Tell me when it’s out