Difference between "toggle polarity" and "invert mask"

When using drawn masks, there is a “toggle polarity of drawn mask” button that shows either a minus or a plus sign and also a dropdown menu called “invert mask” that can be set to “on” or “off”. They are marked with red in the screenshot below.

Masking

As far as I can figure out, these two do exactly the same. I have tried every combination of masks and these settings I can think of without being able to make them behave differently. Therefore I wonder if there is something I have missed. So is there a difference? and if so, what is the difference? I couldn’t find anything about it in the manual, although the topic of masking is very well covered.

1 Like

I would have expected that the ‘+/-’ might toggle the polarity of an individual shape and ‘invert masks’ might toggle the polarity of the entire mask but I agree - they seem to do the same thing.

No, AFAIK. You may combine different shapes into the mask, adding or subtracting them. Invert mask inverts the whole result. Consult the manual for more details. And yes, I understand that it’s usually the last option (for folks like myself), but still…

My conclusions are based on actually using darktable. This may not be correct behaviour but is how it works: clicking on the ‘+/-’ inverts the all shapes in use by a module. I cannot persuade it to invert individual shapes at all, only the mask as a whole.

Then it may be a bug. I never compared the manual with the real behavior but I feel that it must be noticed by some user(s) during such a long time i’s implemented. I don’t use complex masks that often and usually go trial-and-error way if need be. However I’ve got a feeling that either I misunderstand what the manual says or it works somewhat different because I sometimes get unexpected results with the mask. There’s a simple way to find it out: just repeat what manual says in reality and compare)))

Combining individual shapes with different operations is done in the mask manager module. If you try a practical example of using the toggle button and the dropdown menu, you’ll see that they do exactly the same. You can not add one shape, toggle the polarity and then add another shape and expect it to be the opposite of the first. And yes, I have read the manual. Actually several times, during almost seven years of using darktable.

I looked at the manual before I posted the last message. It says ‘each shape before being added can be inverted’ but doesn’t say how and I can’t find a way. However, shapes can indeed be combined within the mask manager so I don’t believe we’re missing any functionality.

I think the conclusion is that the two operations mentioned in the OP are indeed doing the same thing. Perhaps just a bit of tidy-up required to remove the ‘invert mask’ on/off toggle as it’s redundant (since the other method also appears in the combined drawn/parametric mask panel).

Neither could I AFAICR. My understanding is if there is no such way and there is duplicating functionality in the same time than it’s maybe just a bug.

I can’t see the “invert mask” option in the parametric mask I set up. Why aren’t the options between drawn and parametric consistent?

The manual says to use “invert polarity”, but I’m trying to do a detail mask and I just can’t manage to set it up (like at all) with the polarity of that slider inverted…

YOu can do it per channel with parametric mask and for the whole mask you can also select exclusive/inclusive inverted as the inverted option… of the current mode you are using.

There is a bit of nuance to the masking in DT…Try to think of it this way which may or may not help…

THe final or global mask in your module is the combination of the “DRAWN” mask and the “PARAMETRIC” mask or only one or the other if you just use one type. These in turn can each be derived from the combination of elements added. THe final drawn mask is a composite of all the individual shapes… how these interact with each other to make the final drawn mask is controlled in the mask manager. THen you have the parametric mask with several channels… These can be defined and inverted with polarity for each channel… THe key is the mode used for the mask. THere are two. Exclusive and Inclusive… If exclusive is chosen this is like using “and” as the operator so for a pixel to be masked it must satisfy all the requirements of every mask element introduced… So lets say its sky. You mask with a parametric mask but the water in the shot is blue and so is the sky so you use a drawn mask around the sky area so that pixels in the mask are blue and only where it is blue inside the drawn area… This mode is the logic for how the overall drawn mask and the parametric mask are combined to give the final result. In addition it determines how all the parametric channels are combined with each other when the overall parametric mask is constructed… So D + P mask = final mask and they are treated with an “and” logic if you set the mode to exclusive. Drawn sub elements interactions are controlled by the mask manager to derive the drawn mask and parametric channels combine using the selected mode logic in this case “and” when it is exclusive. There is a mode called exclusive inverted which will give you the inverted mask of any overall mask you make while the setting is exclusive. So setting exclusive uses “and” logic to combine the drawn mask and the parametric mask as well as the individual channels of the parametric mask. The individual drawn elements of the final drawn mask are controlled by the settings used in the mask manager… Now lets say instead you use inclusive… well this is the exact same process but using “or” logic… So in this case the mask described above would be the blue sky, the blue water and anything not blue but selected by the entire drawn mask.

So once you start thinking “and” vs “or” then you can sort out what changing polarity might do when the various elements are combined… For example you have a parametric mask and a circle drawn somewhere. If you were to invert the circle then everything outside the circle becomes the new drawn mask and combines with the parametric using “or” or “and” , ie inclusive or exclusive. This give quite a different mask as you can image or see via some experimentation…

2 Likes