darktable page lede image
darktable page lede image

Parametric mask

3.2.8. Parametric mask

The parametric mask feature, formerly called conditional blending, offers fine-grained selective control over how individual pixels are blended. It does so by automatically generating an intermediate blend mask from user defined parameters. These parameters are color coordinates not the geometrical coordinates used in drawn masks.

The parametric mask is a powerful tool with a certain level of complexity. Overview

For each data channel of a module (Lab, RGB) and additionally for several virtual data channels (e.g. hue, saturation) users can construct a per-channel opacity function. Depending on the pixel's value for this data channel this function determines a blending factor between 0 and 1 (or 100%) for that pixel.

Each pixel of an image thus has different blending factors for each of its data channels (real and virtual). All blending factors are finally pixel-wise multiplied together with the value of the global opacity slider (see Section 3.2.6, “Blending operators”) to form a blend mask for the image.

If for a given pixel the blend mask has a value of 0, the input of the module is left unchanged. If for a pixel the blend mask has its maximum value of 1 (or 100%), the module has full effect. Usage

When parametric mask is activated in combobox blend an additional set of tabbed controls is shown.

Channel tabs

Each tab selects a data channel – real or virtual. Modules acting in Lab color space have data channels for L, a, b, C (chroma of LCh) and h (hue of LCh). Modules acting in RGB color space have data channels for g (gray), R, G, B, H (hue of HSL), S (saturation of HSL), and L (lightness of HSL). Consult for example Wikipedia's article on color spaces for a deeper look.

Each tab provides two sliders for its data channels: one for the input data that the module receives and one for the output data that the module produces prior to blending.

You can inspect the image data corresponding to an individual color channel by holding down the shift key while entering the respective slider with the mouse cursor. The center image changes to display the selected color channel either in graycale values or in false colors, depending on the corresponding preference setting in GUI options (see Section 8.1, “GUI options”). You may additionally hold down the ctrl key which lets you see the resulting mask overlaid to the image. When leaving the slider the image goes back to normal after a short delay.

Color channel sliders

With the color channel slider you construct a trapezoidal opacity function. For this purpose there are four markers per slider. Two triangles above the slider mark the range of values where opacity is 1. Two triangles below the slider mark the range values where opacity is zero. Intermediate points between full and zero opacities are given a proportional opacity.

The filled triangles, or inside markers, indicate the closed (mostly narrower) edge of the trapezoidal function. The open triangles, or outside markers, indicate the open (mostly wider) edge of the trapezoidal function. The sequence of the markers always remains unchanged: they can touch but they can not switch position.

A polarity button ( and , respectively) to the right of the slider switches between range select and range de-select function modes with visual confirmation provided by exchanging the upper and the lower triangle markers. These two types of trapezoidal functions are represented graphically in the following images.

Range select function

Range de-select function

A trapezoidal function that selects a narrow range of values for blending.

A trapezoidal function that de-selects a narrow range of values from blending.

In their default state all markers are at their extreme positions, maximum left and maximum right, respectively. In this state a range select function selects the whole range of values giving an all at 100% mask. Starting from there one can move the sliders inwards to gradually take out more an more parts of the image except of the remaining narrow range.

A range de-select function per default deselects the whole range of values, giving an all-zero mask as a starting point. Moving the sliders inwards gradually extends the mask more and more except of the remaining narrow range.

For more information on the polarity feature read Section 3.2.9, “Combining drawn and parametric masks”.

Control buttons

Control buttons help you when designing a parametric mask.

With the color picker button you can select a probe from your image. The corresponding values for the real and virtual data channels are then displayed within each color channel slider. You can switch between point and area sampling mode from within the global color picker panel (see Section 3.3.4, “Global color picker”).

With the invert button you can toggle the polarities of all channels (including a potentially activated drawn mask) and change the method how channels are combined into the final mask. More on that topic can be found in Section 3.2.9, “Combining drawn and parametric masks”.

With the reset button you can put all settings back to their default state. Examples

Colorkey effect

To create a colorkey effect with this poppy blossom in red and the remainder of the image in monochrome, we could apply module monochrome to all parts of the image except for of the saturated red petals.

We choose the hue channel to control our mask as hue provides good separation between the petals and background.

These settings in hue channel construct a parametric blend mask that excludes the red petals. The small white bar in the gradient was obtained by using the color picker on one of the petals and the markers then closely centered on the indicated hue to increase the selectivity of our mask.

The resulting blend mask.

The final image after module monochrome is applied.