Sub topic 9
The Inversion group: Difference, Exclusion, Subtract and Divide
This chapter assumes you are comfortable with layers, layer masks and the base, blend and result model from earlier chapters. It also assumes you know the per-channel formulas and the idea of a neutral color. Here we apply them to the four modes in the Inversion group, which Photoshop also calls the comparative group.
What the group does
Most blend modes push the base darker or lighter. The Inversion group modes compare the blend layer with the base and return the gap between them. When the two layers match, the result is black or white. When they differ, the result shows how much they differ.
The group has four modes:
- Difference: the absolute difference between base and blend.
- Exclusion: a lower-contrast version of Difference.
- Subtract: the blend value taken away from the base.
- Divide: the base divided by the blend value.
All four work on each channel separately, with values from 0 (black) to 1 (white), as in the Multiply and Screen formulas from earlier chapters.
| Mode | Formula (per channel) | Neutral color | Typical use |
|---|---|---|---|
| Difference | `abs(base - blend)` | Black | Alignment checks, comparing versions, inverting with white |
| Exclusion | `base + blend - 2 * base * blend` | Black | Soft inversions, graphic color effects |
| Subtract | `max(base - blend, 0)` | Black | Removing a known layer, channel math |
| Divide | `min(base / blend, 1)` | White | Flat-field correction, removing a lighting gradient |
The formulas in code
This script implements the four modes and compares them on one pair of values.
def clamp(value):
return max(0.0, min(1.0, value))
def difference(base, blend):
return abs(base - blend)
def exclusion(base, blend):
return base + blend - 2 * base * blend
def subtract(base, blend):
return clamp(base - blend)
def divide(base, blend):
if blend == 0:
return 0.0 if base == 0 else 1.0
return clamp(base / blend)
base, blend = 0.6, 0.2
print(round(difference(base, blend), 3)) # 0.4
print(round(exclusion(base, blend), 3)) # 0.56
print(round(subtract(base, blend), 3)) # 0.4
print(round(divide(base, blend), 3)) # 1.0 (3.0 clipped to white)
# Matching pixels:
print(difference(0.5, 0.5)) # 0.0 (black)
print(divide(0.5, 0.5)) # 1.0 (white)
print(exclusion(0.5, 0.5)) # 0.5 (mid gray)The last three lines show a key difference. Identical pixels give black in Difference and white in Divide. In Exclusion, two mid-gray values give mid gray.
Difference
Difference subtracts the darker value from the lighter one on every channel. The order of the layers does not matter, because abs(base - blend) gives the same result either way.
- Black is neutral. A black blend layer leaves the base unchanged.
- White inverts. A white blend layer gives
1 - base, the same as Image > Adjustments > Invert. - Identical pixels become black. This makes Difference the standard mode for comparing two images.
- Mid gray gives a result that is bright where the base is dark or bright and dark where the base is mid-toned. This is harder to predict, so avoid it as a tool.
Colors also change. A pure red blend over a white base gives cyan, because the red channel becomes 0 and the green and blue channels become 1.
Alignment checks
Difference shows exactly which pixels differ between two versions of an image. Typical cases are two exports of the same file, an aligned stack of photos, or a retouched copy against its original.
- Put the two versions in one document as separate layers.
- Set the top layer to Difference.
- Look at the result. Black areas are identical. Bright areas or colored fringes are differences.
- To make faint differences visible, add a Levels or Curves adjustment layer above both and pull the white point in sharply.
- Nudge the top layer with the arrow keys (or use Auto-Align Layers) until the image goes as black as it can.
Exclusion
Exclusion follows the same idea as Difference with less contrast. The formula base + blend - 2 * base * blend pulls mid-tones toward gray. When one layer is 50% gray, the result is 50% gray no matter what the other layer is. In Difference, a mid-gray blend still produces a result with plenty of tonal range.
- Black is neutral, and white inverts, as in Difference.
- Midtones flatten toward gray, so Exclusion looks washed out next to Difference.
- Colors shift in a way that depends on the channels, so a colorful blend layer gives odd, strongly tinted results.
Exclusion is rarely the right tool for realistic retouching. It is useful for stylized work: duotone-style effects, gradient overlays on posters, and glitch-like color shifts. A common trick is to put a solid color or gradient in Exclusion mode over a photo and lower its opacity for a quick, graphic color shift.
Subtract
Subtract takes the blend value away from the base value. Anything that would go below 0 is clipped to black. In 32-bit mode, values below 0 are kept instead of being clipped.
- Black is neutral. White turns everything black.
- Order matters: swapping the layers changes the result, unlike Difference.
- Subtract darkens everything, and it removes a bright feature from the base completely when the blend layer holds the same values.
Subtract works well with channel and mask operations. For example, you can take a layer that holds a light haze and subtract a copy of the haze to recover the original. This depends on knowing that the base is original + haze. The mode also pairs with Apply Image and Calculations, where Subtract (with a scale and offset) builds the high-pass-style layers used in frequency separation.
Divide
Divide is the opposite operation. It divides the base by the blend value, and any result above 1 is clipped to white.
- White is neutral. Dividing by 1 leaves the base unchanged.
- Black is extreme. A black blend value divides by zero, so any base value above zero becomes white.
- Mid gray doubles the base, so Divide with a 50% gray layer acts like a strong brightening.
- Identical pixels give white.
Divide is the standard tool for flat-field correction. If a photo has an uneven lighting gradient or a lens vignette, you can create a smooth picture of the lighting problem and divide the photo by it. Regions where the light is weak, which have low values in the gradient layer, are brightened. Regions where the light is strong are left near their original values.
A workflow for removing a vignette:
- Photograph or build a blurred, grayscale image that holds only the lighting falloff, for example a Gaussian-blurred copy of an evenly lit surface.
- Place that layer over your photo.
- Set it to Divide.
- Adjust the layer's Opacity to control how much of the correction is applied.
Because the dividing layer is the "neutral white" case in the middle of the frame, the center stays unchanged and the edges brighten.
Choosing between the four
| Goal | Mode | Why |
|---|---|---|
| Check whether two layers are aligned | Difference | Matching pixels go to black |
| Invert the image on a layer | Difference with a white fill | `1 - base` per channel |
| Gentle, flat inversion or graphic color shift | Exclusion | Lower contrast, mid gray stays gray |
| Remove a known layer from a composite | Subtract | Direct arithmetic removal |
| Fix a lighting gradient or vignette | Divide | Proportional correction, white is neutral |
Common mistakes
- Expecting black to be neutral in Divide. It is white. A black layer in Divide makes the result white wherever the base is not black.
- Using Difference to compare images of different sizes or resolutions. The layers must be the same dimensions and scale, or the edges will glow even where the content is the same.
- Comparing images in different color spaces or after a lossy save. JPEG compression adds small differences that appear as faint noise, so a Difference result is rarely perfectly black.
- Forgetting that Subtract and Divide are not symmetric. Swapping the layers gives a different result, so check the layer order first.
- Stacking Inversion modes inside a layer group set to Pass Through. The group lets the mode act on everything below. To limit the effect to the group, set the group to Normal.
Exercise
You have a photo of a landscape in the layer "Base" and a blurred grayscale layer "Falloff" above it, which is bright in the center and dark at the corners. The photo has a dark vignette. Which mode should "Falloff" use to brighten the corners, what is the neutral color for that mode, and what happens to pixels where the "Falloff" layer is pure white?
Show answer
Use Divide. White is the neutral color for Divide, so pixels where "Falloff" is pure white (the center) keep their original values, because dividing by 1 changes nothing. Where "Falloff" is darker (the corners), the base is divided by a number below 1, so those pixels are brightened, which cancels the vignette.