combine parametric masks

Is it possible to combine parametric masks in Darktable?

To give a concrete example, suppose I want to make a mask that selects based on hue, around skin tones and blue-ish hues (for eyes). I can do one or the other, but can I combine them (inclusive)?

I would do that in two different instances.

1 Like

How can I do that if I want something to happen outside these masks (eg invert inclusive)?

For a concrete example, desaturate everything but the blues and the skin tones in color balance.

Inclusive is how it interacts with drawn mask to create the overall mask for the module…multiple instances is the way for you to do this

The drawn mask is an extra degree of freedom I want to preserve for something else.

Sorry if I am not getting something obvious, but for me the problem with multiple instances is that if I desaturate eg everything but the blues in an instance, I already lose color information for the skin tones, and cannot deal with that in a multiple instance.

To make a concrete example: desature greens in the image below by selecting reds and blues (not selecting green, that’s an obvious solution for this toy example).


So why not mask for the blues you want to desaturate and then restrict where that happens with a drawn mask so skin tones are not touched?? Then address the skin tones in a second instance…. I am likely not getting your problem…someone will likely have a better answer for you… Drawn masks are highly flexible so I am not sure what you need to reserve it for …use as many as you need and select how they interact in the mask manager….

This is feasible but (slightly) tedious, as it requires 3 instances of a module: desaturate between

  1. red and skin tones,
  2. between skin tones and blues, and
  3. blues and red.

Currently one can have multiple drawn masks elements but a single parametric mask selection per module, but making parametric masks first-class would make darktable more flexible.

1 Like

yes, thats a result of a design that expects a continuous range within a parameter to be selected. But even if you can select several ranges for one parameter there’ll be plenty of usecases to combine this with inclusive or exclusive further ranges in other parameters. So it’s better to use several instances then just picking one of multiple scenarios to implement this.
Unless the pixel pipe is nodebased allowing sequential or parallel edit nodes (like in davinci resolve) there won’t be a general solution for having multiple ranges within one parameter.

Your best bet is to provide an image and put it on Playraw and describe what you want to do to this image…there may be a more efficient method than the extra modules but also this is the darktable way and works with the pipeline….

I understand the problem. One option is to cover most areas with parametric masks, and then use drawn masks (which you can combine with parametric ones) to fine-tune the selection. I know this does not answer your question; as @MStraeten wrote, it not possible to do with a single module instance using darktable’s parametric masks.

1 Like

I agree with you and given the current DT pipeline…would you not then have to possibly have a second way to handle when multiple parametric masks in the same module overlapped so you could define the skin tones but a second parametric mask on the blues or reds might have some overlap so the logic of combining the drawn masks with each other, the parametric masks with each other and the various channels possible in each of the parametric masks, and how the drawn masks interact with the parametric mask would get pretty complicated… at least for me… :slight_smile:

I don’t see a conceptual problem, all masks (drawn elements, parametric masks) could be combined using the same rules as currently.

My understanding is that mask components do not “interact”, they just get combined.

Thanks. I opened an issue

Well at least for me as I understand it each module has a global mask. The mask has two components. The parametric mask and the drawn mask. The parametric mask can have multiple channels so each additional channel further restricts or targets the parametric mask. The drawn mask can have multiple elements and how they interact is controlled by the mask manager ie union difference etc… to derive the resulting overall drawn mask. Then you have the interaction of these two elements…Everything masked by the drawn mask has a value of 1 for the drawn mask…everything else in the image is considered as zero. The same for the parametric mask…masked will be one and the rest of the image is zero wrt the parametric mask… The rule for how areas of the drawn mask that overlap with the parametric mask are resolved to create the resultant mask are determined by inclusive and exclusive setting. This handles areas of overlap that are 0 for one mask and 1 for the other, 1 and 1, and where both masks zero. Toggling any element in this construct by inverting makes 1 become 0 and the reverse so it will affect the result given the mode in place for combining the drawn and parametric elements of mask… If you added extra parametric masks would they not have to be resolved the way the drawn elements are in the end to give one parametric mask that is combined with one drawn mask to yield the resulting mask for the module…and given that would that actually achieve what you wanted… just me thinking out loud… :slight_smile:

I figured out a workaround with raster masks.

Specifically, it can be done like this:

  1. Pick a module that (a) has a no-op mode and (b) comes earlier in the pipeline than the change you want to make (eg exposure with zero correction). Create one instance for each parametric mask you need.

  2. Use each mask in subsequent corresponding instance of the module you want to apply as a raster mask.

Trivial example attached.
20211114_0001.png.xmp (6.8 KB)

(EDIT: also added this as a comment to the issue)

1 Like