Photoshop channel math: add subtract intersect

Once you’re getting the hang of luminosity masks, there are several ways you can combine them to make even more powerful masks and selections. Specifically, I’m referring to adding, subtracting, and intersecting selections, masks, or channels in Photoshop. In this tutorial, we’ll cover why you should use them and demystify how they work.

All of them work from a principle of starting from your current selection/mask/channel and then modifying it with another in order to produce a more targeted result. To keep the discussion simple, I’m simply going to refer to “selections” for the rest of the article, but the concepts apply equally to masks and channels. 0% selected is the same as black (0.000) in a mask/channel and 100% selected is the same as white (1.000) in a mask/channel.

 

Subtracted selections

These allow you to remove something from your current selection in a proportional way (ie, the pixels targeted by this selection but NOT that one). This is a particularly powerful tool for enhancing shadow detail. If you take a brightness adjustment layer and starting painting a mask through a D3 selection, you will definitely lighten the shadows. But you will be brightening the blackest detail more than the other shadow values. This will result in a muddy, low contrast mess. What you really want to do is to leave pure black alone and instead only brighten the slightly brighter dark tones. You can subtract a more restrictive darks selection such as D5, which will exclude the pure blacks and give you exactly what you need. Now when you paint through it, the shadow detail will be brightened, but without reducing contrast by lightening the pure blacks.

The concepts here are pretty simple when you’re dealing with ares which are fully selected or protected, but much less obvious when you start to consider all the partial values in between, which is the nature of all luminosity masks. If you remove a 100% selection from anything, the result will be 0% selected (or black in the channel/mask). What confuses people is that this isn’t just a simple subtraction of two numbers. If you subtract a 40% selection from a 50% selection, the result is not 10% selected, it’s actually 30%. The way Photoshop thinks about this is that you are starting from a 50% selection and then going 40% of the way from there to 0% (black).

To show you the actual math, let’s first need to define a few terms:

  • currentVal = the current value of your selection, mask, or channel
  • modifierVal = the value of the selection you wish to add to, subtract from, or intersect with your current one
  • The math is based on working with scalars, which are values ranging from 0.000 (black) – 1.000 (white), which work like percentages (ie, 0.535 would mean 53.5%). If you are reviewing the info panel, you will only see the correct values if you switch the display to show grayscale(K) values as 32-bit values.
  • The math is done directly on these grayscale values. It does not matter which colorspace, working space or bit depth your image uses, this is the correct way to view the mask/channel values if you want to understand how the add, subtract, and intersect work (ie, Photoshop internally uses conceptually similar values, regardless of bit depth or how you choose the view the numbers).

Subtract => currentVal – modifierVal * (currentVal – black) => currentVal – modifierVal * (currentVal – 0.000)
Which can be simplified to: Subtract => currentVal – modifierVal * (currentVal)

To learn more about subtracted selections, be sure to check out these previous tutorials:

Added selections selections

This allows you to increase the areas targeted by your selection (ie, the pixels in this selection OR that one). Most likely, you’d be using this to load two alpha channels for different subjects in order to work on both at the same time. For example, you may have selected each building in a cityscape individually for control but need to work on all of them together at some point. Generally speaking, you’re much less likely to use addition for luminosity selections than the other methods. But you might occasionally want to do something like target both zones 4 and 5 at the same time.

The way Photoshop thinks about this is that you are going from the current value some percentage of the way towards white. So adding a 40% selection to a 50% one would take you 40% of the way from 50% to 100% (white), which is 70%.

Add => currentVal + modifierVal * (white – currentVal)
Add => currentVal + modifierVal * (1 – currentVal)

 

Intersected selections

This allows you to restrict the areas targeted by both selections (ie, the pixels common to both this selection AND that one). This is particularly helpful for refining based on two criteria, such as pixels which are both L2 and yellow, so as to separate the bright yellow building from the bright blue sky. Or for choosing pixels which are both D4 and inside the general area you just targeted with a lasso selection. This is conceptually similar to working with group masks, but lets you do everything in a single step when that’s your preference.

The math here is a much simpler multiplication. So intersecting a 40% selection with a 50% one gives you 40% of 50% or 20%.

Intersect => currentVal * modifierVal

 

Greg Benz Photography