Parametric masks for fore- and background

I recently saw in a video which featured Adobe Lightroom and the creation of masks for different things such as “background” or “foreground” but also things like “sky” or “person”.
I thought that in some instanced that could be really helpful also in darktable.
I played around with several images and eventually also found this feature request: [FEATURE] parametric mask by edge detection · Issue #7628 · darktable-org/darktable · GitHub

As far as I can tell, there is no magic way to do this, and you have to find the parameter that suits the image the best. For example, in most cases with relatively homogeneous background color, hz is a straightforward choice. For other images Jz seems to work pretty good. I guess that in the end it involves a lot of experience by trial and error and also a lot of manual corrections with additional drawn masks (but that seems to be the case in Lightroom too)…
What I found out just now is that you can press c to show the image coded in the particular channel you are in. That is pretty neat. It makes it easier (although not super easy :D) to find the parameter you want to create the mask in.

Thus I would like to know: How do you do that? What tools did I miss? Have you found the “magic wand” in darktable to create such masks easily?
This thread also caught my interest: Importing masks in darktable which would be really interesting if masking could be done in an external tool.

I use drawn and/or parametric masks and apply refinement which is an edge-aware filter.

The line I drew (no further tuning via combining the drawn mask with a parametric one):

Without refinement:


I am wondering if there really is any edge-aware adjustment be applied by the suggested method here as the four sliders being adjusted don’t appear to have that function. I personally use the details threshold slider a lot for sharpening and denoising noisy images and that is maybe edge-aware but the feather, blurring. opacity and contrast sliders possibly are not edge-aware. I am willing to be corrected if I am wrong.

I wonder if the feature @reox refers to is an AI tool in lightroom?

You can use the autopicker to give you are starting range for an area, then if you use the setting for inclusive or exclusive you can determine if the channels are used as “OR” type selections or “AND” type selections…this can help, ie to combine channels… but usually the most effective is parametric mask of one or more channels to capture what you want…extend it until it selects what you want … often other areas are selected but now you draw a rough drawn path to isolate your area like the sky…

There is some open source auto selection solutions but I am not sure it is easy to just port this sort of thing into DT unless someone is skilled and determined …

DId you compare image 2 and 3?

Yes, but is that edge aware? I am also not sure this would resolve the issue for the original poster. I nearly always feather my edges with the slider here to make an invisible transition, but I don’t see these sliders as helping to select the foreground, background or sky. They certainly help with the edge transition, but I feel not in an edge-aware fashion except maybe for the details threshold slider.

Feathering is definitely edge aware isn’t it? It certainly behaves that way, with a little help from the other mask sliders.

I miss these old blog post…

There is a demonstration here…

Also one of the better one’s for the retouch module

It is feathering the edge and only the edge if we are going to call that edge aware then yes. I interpreted the phrase as meaning to determine the edge of the subject. Maybe I am trying to read to much into it, but I am still not convinced this helps the OP.

1 Like

Its just an edge aware blur as opposed to a dumb blur which often gets called feathering or a blur with a gradient might be called feathering often as well or its how I think of them… …

1 Like

oh yes it does help! I used feathering on a regular basis but haven’t understood the concept fully. Now it makes me use it more deliberately and do not fear to use coarser drawn masks.
I posed the question quite open on purpose :slight_smile:

This is also a good hint and yesterday I found out you can do a lot more boolean operations in the mask manager. Pretty funky stuff!

Uhm, I have no idea what they do and I never used it myself. The last time I used Lightroom was probably 10 years ago (and that was still LR3)…
I guess the feature they showed in the video was this:
I would guess that they probably have some neural network in the background, which does this image labeling/masking.

I am so glad you got answers that help you. BTW, if you activate the show mask feature in DT you can see the difference in feathering using the doted line and using the slider.

The dotted line feathering adjustment sets up a gradient from the solid line to the dotted line and grabbing nodes on the dotted line you can customise this gradient to increase it or decrease it in certain parts of the masks edge.

On the other hand the feather slider creates an even gradient both inside and outside the line giving a different outcome rather than being two different ways of achieving the same feathering.

With parametric masks I find a very small amount of the feathering slider such as 1 px can give smoother transitions.

The reason I have picked DT over any other free or paid program is the great parametric and drawn mask options that I really appreciate. I believe the latest subscription of LR gets you AI selection which is where I went off on that tangent with your original post.

The feathering slider belongs to the refinement block. It takes the ‘average’ of what is currently selected, and analyses contents (not AI, but pretty effective). It’s not just a ‘gradient inside’. Look at this one (image credit: found on the internet, sorry):


It’s a pretty rough selection over the dragon. Without refinement:

  • it does not cover all of the dragon
  • it covers the sky visible through the statue.

With refinement, the selection is extended to other parts of the dragon:

Increasing the radius: the sky gets excluded!

Adjusting the opacity and contrast of the mask:

With a more carefully drawn mask and perhaps more, smaller masks, and involving parameters (to avoid bleeding over to the grass), the result could be further improved.


This is ON1 not LR but likely similar…you can select things like this also it does autoseletions like animals foliage etc that are available in the drop down when you go to mask a filter they call it…

After all this time and so many usages … I never realized that the ‘fade’ was occurring both inside and outside of the primary line.