overview
Table of Contents
Masks allow you to limit the effect of a module so that it only applies to certain parts of the image.
A mask can be regarded as a grayscale image where each pixel has a value between 0 and 1.0 (or between 0% and 100%). This value is the opacity and is used to determine how much a module affects each pixel. Where the mask is 0 the module has no effect; where it is 1.0 the module has its full effect.
Note: The masking system was redesigned after darktable 5.6. If you are familiar with the drawn, parametric and raster mask modes and the mask manager, read migrating from classic masks first.
#building blocks
Every mask in darktable is built from the same few pieces.
- element
- A single source of opacity. There are four kinds of elements:
- a drawn shape – a brush stroke, circle, ellipse, path or gradient drawn on the image;
- a parametric element – a range of values of one color channel (for example a range of luminance or of hue);
- a raster mask – the final mask of another module, earlier in the pixelpipe;
- an AI object – an object selected by clicking on it, with the help of an AI model.
- group
- A container that combines its members (elements and other groups) into one mask, using a single operator (for example union, intersection or difference). Groups can be nested inside other groups, up to eight levels deep.
- operator
- How a group combines its members. A group applies its operator to its members starting from the bottom one and working upwards, in the same way as modules are applied in the pixelpipe. See groups & operators.
- whole mask
- The group at the top of the tree. It holds everything else, and its result is the module’s mask. The whole mask is a group like any other: it has an operator, an opacity, and can be inverted and refined.
So a mask is a tree: elements are its leaves, groups are its branches and the whole mask is its root. Each kind of element can be combined with any other, in any group, with any operator.
#what each level can do
Every element and every group has the same set of controls, which are applied in order before the result is passed to the group above:
- refinements – details threshold, feathering, blur, brightness and contrast (see refinements).
- invert – select what was left out, and vice versa.
- opacity – scale the result. A member at 50% opacity counts half as much in its group. The opacity of a group multiplies the opacities of its members.
In addition, any member can be temporarily disabled (it then contributes nothing) or soloed (it is then the only thing that contributes to the mask).
Finally, the whole mask is applied together with the blend mode and the global opacity of the module.
- Each element produces its own opacity values. These are then refined, optionally inverted and scaled by the element’s opacity, before being passed to the group. The four elements shown here are, from left to right, a drawn shape, a parametric range, a raster mask and a second drawn shape.
- A group combines its members with its operator. It then refines, inverts and scales the result, as an element does, before handing it on.
- The whole mask is a group like any other. Here it combines the result of the group from step 2 with a further element.
- The mask is scaled by the global opacity of the module and used to blend the module’s output (at the bottom) over its input (at the top), using the chosen blend mode.
#a first mask
The quickest way to see how this works:
- Expand a module that supports masks (for example exposure).
- In the mask panel at the bottom of the module, click the
toggle to switch the mask on. The mask starts with the default layout – a single group (the whole mask) ready to receive shapes. - Click a shape button in the toolbar (for example the ellipse) and click on the image to place it. The module is now applied only inside the ellipse.
- Click a parametric channel button (for example Jz or L) to add a luminance element and narrow its range with the sliders in the controls section.
- The new channel was added to the same group as the ellipse. The group’s operator defines how the two elements of the mask interact: for example, union applies the module inside the ellipse or to the selected tones, whereas intersection applies it only to the selected tones inside the ellipse.
Groups & operators explains how to plan and read more complex masks.
#reusing masks
Masks can be shared between modules in several ways:
- Drawn shapes and AI objects can be linked into the mask of another module (editing one changes it everywhere) or copied (independent copies) – see drawn shapes: reusing shapes.
- Parametric elements can be copied from another module that uses the same blend colorspace – see parametric elements.
- The final mask of any active module can be used, as a raster mask, by any module later in the pixelpipe.
- The layout of a mask (its groups and operators, without elements) can be saved as a group layout preset and applied in any module.
Modules can also be copied with their masks, and stored in styles and presets; their shapes are saved with them (see presets and masks).
Note: A locked mask is kept as it is when a module is reset, or when a preset, a style or pasted parameters are applied to it.
