top of page
Ed Dozier

The Darktable Photo Editor, Part 2: Image Masking


If you haven’t read it, you should take a look at my Darktable Overview article prior to reading this . It will give you some needed context for the use of this masking discussion.

Masks let you make changes to selected portions of the image. Most of the Darktable “darkroom” edit modules have a blend option, which is where you access the masking operations.

The blend operation has options for “drawn mask”, “parametric”, or “drawn & parametric mask”. The default blend is “off”, or no masking. Until you select something other than “off”, you won’t see any masking controls.

Any photo editor that doesn’t have a good set of masking tools just isn’t fully useful for me. This is the main weakness of Adobe Lightroom, in my opinion. Darktable has what you need.

Drawn Mask

The “drawn mask” has options to use a brush (drag a circle around to trace a wide path), a circle, an ellipse, a gradient, and a path (to encircle a complicated shape).

You can change the size of drawn masks using the mouse scroll wheel. If you use the Shift button with the scroll wheel, you can change the feathering width on the mask edge, and the Control button/scroll wheel will change the opacity of the mask.

A typical module “blend” mask dialog: the “drawn mask”

You’ll note in the above “drawn mask” dialog, you get icons indicating (shown left to right) a brush (looks like a pencil), circle, ellipse, path, and gradient.

To see the masking bounds, click on the little “hole in a square” icon at the bottom of the dialog. The mask bounds will be rendered in yellow. Pure yellow will indicate an opacity of 100%, for the full masking effect. The icon is a toggle, so click it again to hide the yellow mask. You’ll generally want to enable this feature while you draw the mask, but if you don’t, there’s still an indicator of where you draw.

To toggle the module actual masking effect on or off, click on the “eye” icon at the bottom of the dialog.

The “blend mode” is used to alter the extent of the mask effect on the selected pixels, such as color, lightness, or normal (all).

The mask tool (such as the brush) size is controlled by the mouse scroll wheel. The mask hardness is controlled by Shift-scroll, and the opacity is controlled by Ctrl-scroll.

You can also “invert” the “drawn” mask effect by selecting On/Off for the “invert mask” near the bottom of the drawn mask dialog.

After you draw a mask (and release the left mouse button), you can alter it after the fact. Click the “view mask” icon (square with a hole in it) to make the yellow mask visible. Click on the drawn mask to select it, and you can still use the scroll wheel to alter its size, feathering (with shift-scroll), and opacity (ctrl-scroll). There are also little square “handles” along the mask path you can select and drag. If you want to rid the path, just click the right mouse button when the mask is selected.

If you leave the module and later return to alter the mask, you’ll need to click the “edit mode” button to the right of the “drawn mask” text. The button looks like an arrow pointing at a dashed line. If you want to prevent mask alteration, just re-click the same “edit mode” button.

To draw a path for a mask, use the mouse to left-click some nodes on the path where you want it to be (the “destination”). When you have enclosed the shape you want, click with the right mouse button to finish the path.

If you don’t want rounded lines in the path, then use Ctrl-click to get sharp corners and straight lines on the path segments. This works great for selecting things like a box. In this case, just enclose the straight-edged shape without having to right-click to finish it.

In the path “edit” mode, you can change nodes back and forth between smooth and straight by using Ctrl-click on the node.

To alter the path, use the left mouse button to select the path and also to select nodes to drag.

Path mask showing the nodes that define it

You can delete a path node by first selecting the node (it gets highlighted) and then right-click. Be careful, because if you just select the path and right-click it, the entire path will be deleted.

Mouse-scroll to alter the size of the whole path, and use Shift-scroll to alter its edge feathering.

Parametric Mask

Blend: “parametric mask”

A module “parametric mask” blend selection will draw a mask based on pixel characteristics, instead of where the pixels are in the picture. If you want to select something like a garment by its color or a light background, this is what you would use. You can generate some extremely complicated masks with this technique, which would be impossible to manually draw.

Depending upon your edit module’s color space (e.g. Lab space or RGB), the dialog will look different. The example above is for Lab color space, where “L” is “lightness”, “C” is “chroma” (saturation), and “h” is “hue” (color tint). If you select “L”, the slider bar will switch to black-and-white.

To select a photo color, use the eye-dropper “color picker” icon (shown above). To invert a color channel, click on the “invert” icon as shown above. There is also a “reset” icon to return to default settings.

There will be a little white vertical bar (see the “picker color bar” above) drawn on the “input” slider to indicate the color picker selection. Triangles above and below the little “picker color bar” must be dragged to narrow the selection range (from 100% to 0% opacity). The range inside the solid triangles will be 100% opacity, and the hollow triangles control the extent of the mask feathering. If you don’t slide the triangles to narrow the selection, the whole image will be selected by the mask, and your image will be a giant yellow rectangle.

Just like the “drawn” mask, the parametric mask has an “eye” icon to turn the mask effect on/off and the circle-in-square icon to view/hide the yellow mask itself. You’ll need to exhibit a little patience when clicking the “eye” to see the effect fully rendered on your computer.

Drawn and Parametric Mask

Drawn and Parametric Mask, parametric shown

It’s possible to have both kinds of masks in a single module, called “drawn & parametric mask”. Shown above, I selected a small area of the structure (via the eyedropper) and made a parametric mask of the “L” channel, where I dragged the little input triangles to select a range of “lightness”. I clicked on the “show mask” button, so the masking results can be seen in yellow while I adjusted the slider triangles.

Note the parametric mask sliders are shown in black-and-white here, because I chose the “L” channel. If I had chosen the “h” channel hue, then the slider would be shown as full-color.

The mask above “spilled over” a little bit from what I wanted. This is really common with parametric masks. You typically need to do some cleanup using a drawn mask.

Drawn and parametric mask, path ‘drawn’ on top of parametric

Shown above, I used the “path” and drew over the parametric mask to add some more masking. The little “toggle polarity of drawn mask” is set to a “+”. This lets me erase part of the parametric mask using a drawn mask and clean up its boundary. This demonstrates how I was able to combine the two kinds of masks together.

As shown above, I held down the Control key while clicking the points for the drawn “path”. This keeps the mask edges straight, instead of rounded. I used the “Shift-Scroll” mouse scroll wheel to reduce the drawn mask path feathering. Since I wanted this path to be an enclosing shape, I clicked the right mouse button to complete the shape.

Portrait retouching mask

If you’re a fan of using Gaussian blur on skin when retouching portraits (you probably should be), I’d recommend that you set the mask “opacity” slider (just underneath the “blend mode”) to something around 90% for starters. You want a little skin texture to peek through the mask.

You’ll probably be using the “brush” drawn mask the most for this.

Lowpass, Gaussian blur with mask to avoid eyes, mouth, nostrils

The “effect” group “lowpass” module is what you want to be using for Gaussian blur.

Summary

As you can see, there are many, many mask features in Darktable. I hope this little guide will help ease the pain of learning how it all works.

1,363 views
Recent Posts
Archive
bottom of page