How are selection masks added to or subtracted in GIMP?

I have two questions about what happens when I select “Subtract from Selection” or “Add to Selection” from the context menu for a selection mask while another selection is active.

First, am I correct in assuming that the grayscale values for two selections are literally being subtracted or added numerically?

If so, then are any resulting values that exceed pure white or pure black clamped at those values? In other words, and assuming that the grayscale values run from zero to one, are results less than zero set to zero and results greater than one set to one?

That seems to be the case, and it makes sense to me for creating luminosity masks for various degrees of lightness or darkness. I hope the answer is “Yes”, or else I’m confused again.


Not really answering all your question …but …
If your luminosity masks end up as channels then these can be applied as selections with the add / subtract / intersect options.

This using the Saul Goode luminosity script.

I am not sure how to answer your question. I presume you are trying to make luminosity masks. Are you using a script for this or how are you creating them?

This tutorial may help you or others interested in luminosity masks.

Yes, that is exactly what I’m doing. My question was about what goes on “under the hood” when I do that. I can look at the grayscale selection masks and see the effects of the menu commands, but I don’t understand why they behave the way they do.

I’m really just asking about the algorithms that are applied to the grayscale images.

It is possibly worth asking here:

Thanks for the link, rich2005. How many Gimp forums are there? I’m here on pixls and also on, but I hadn’t seen yet!

I’ll have to create an account there as well, and then maybe I’ll ask this question there, if I’m still confused.

Update: that thread was excellent! I think understanding gamma correction (which I’ve always wondered about but never really investigated) is what I need to understand the answer to my question.

Also : Layer Mode: Addition equation is working differently to official guide

Thank you! That discussion was exactly what I was looking for.